You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "m.s." <da...@arcor.de> on 2009/03/30 13:51:43 UTC

Setting a path in message header with Camel-http 2.0M1

I use Camel-http 2.0M1 to send messages to an http endpoint. The URI is
defined in the endpoint, but I would like to specify the last part of the
path dynamically in the header. 

So I tried to set the header as follows (before I send the message with
ProducerTemplate.sendBodyAndHeader(...):

        Map <String,Object> header = new HashMap();
        header.put(HttpConstants.HTTP_METHOD, "POST");
        header.put(HttpConstants.HTTP_URI,
"http://localhost:8080/myService");
        header.put(HttpConstants.HTTP_PATH, "testPath");

But the path is ignored and the message is sent to
http://localhost:8080/myService (or the URI defined in the endpoint if I
delete the third line).

Thanks for any hints on what I do wrong,

M.S.
-- 
View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22781504.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Setting a path in message header with Camel-http 2.0M1

Posted by Claus Ibsen <cl...@gmail.com>.
Just for the record. The patch have been applied to trunk.

On Wed, Apr 1, 2009 at 5:42 PM, m.s. <da...@arcor.de> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>>> Now, the HTTP_PATH is appended to the HTTP_URI or the URI from the
>>> endpoint
>>> if it is provided as header.
>> Great that is what it should do.
>>
>>>
>>> Maybe there should also be a check if the URI ends with "/" and the path
>>> starts with "/" to avoid URIs like http://myUri//myPath . Could add it
>>> tomorrow if required.
>> Yes please add this check as well.
>>
>> If possible please provide unit test as well.
>>
>
> OK, I added a check to ensure that there is exactly one "/" between URI and
> Path.
> A unit test extending the HttpGetTest from the camel-http component is also
> included in the patch.
>
> M.S:
>
> --
> View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22829424.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Re: Setting a path in message header with Camel-http 2.0M1

Posted by "m.s." <da...@arcor.de>.

Claus Ibsen-2 wrote:
> 
>> Now, the HTTP_PATH is appended to the HTTP_URI or the URI from the
>> endpoint
>> if it is provided as header.
> Great that is what it should do.
> 
>>
>> Maybe there should also be a check if the URI ends with "/" and the path
>> starts with "/" to avoid URIs like http://myUri//myPath . Could add it
>> tomorrow if required.
> Yes please add this check as well.
> 
> If possible please provide unit test as well.
> 

OK, I added a check to ensure that there is exactly one "/" between URI and
Path.
A unit test extending the HttpGetTest from the camel-http component is also
included in the patch.

M.S:

-- 
View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22829424.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Setting a path in message header with Camel-http 2.0M1

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Apr 1, 2009 at 2:05 AM, m.s. <da...@arcor.de> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> If you fancy take a stab at providing a patch then feel welcome
>> http://camel.apache.org/support.html
>>
>> And please create a ticket in JIRA for this bug.
>>
>
> Hi,
>
> I created a ticket earlier today and just tried to provide a patch. I am not
> sure about the procedure, just attached the patch here:
> https://issues.apache.org/activemq/browse/CAMEL-1504
>
> Now, the HTTP_PATH is appended to the HTTP_URI or the URI from the endpoint
> if it is provided as header.
Great that is what it should do.

>
> Maybe there should also be a check if the URI ends with "/" and the path
> starts with "/" to avoid URIs like http://myUri//myPath . Could add it
> tomorrow if required.
Yes please add this check as well.

If possible please provide unit test as well.
>
> M.S.
> --
> View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22817366.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Re: Setting a path in message header with Camel-http 2.0M1

Posted by "m.s." <da...@arcor.de>.

Claus Ibsen-2 wrote:
> 
> If you fancy take a stab at providing a patch then feel welcome
> http://camel.apache.org/support.html
> 
> And please create a ticket in JIRA for this bug.
> 

Hi,

I created a ticket earlier today and just tried to provide a patch. I am not
sure about the procedure, just attached the patch here:
https://issues.apache.org/activemq/browse/CAMEL-1504

Now, the HTTP_PATH is appended to the HTTP_URI or the URI from the endpoint
if it is provided as header.

Maybe there should also be a check if the URI ends with "/" and the path
starts with "/" to avoid URIs like http://myUri//myPath . Could add it
tomorrow if required.

M.S.
-- 
View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22817366.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Setting a path in message header with Camel-http 2.0M1

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 31, 2009 at 10:20 AM, m.s. <da...@arcor.de> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>>
>> Could you take a look in the camel-http component?
>> I suspect it does not concat the HTTP_PATH and HTTP_URI headers.
>>
>> Could be a glitch in there.
>>
>
>
> Hi,
>
> I think you are right. In the HttpProducer.createMethod() of the camel-http
> component, the URI is taken from the HTTP_URI header or the endpoint, but
> the HTTP_PATH header is not concatenated.
>
If you fancy take a stab at providing a patch then feel welcome
http://camel.apache.org/support.html

And please create a ticket in JIRA for this bug.


> M.S.
> --
> View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22800487.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Re: Setting a path in message header with Camel-http 2.0M1

Posted by "m.s." <da...@arcor.de>.

Claus Ibsen-2 wrote:
> 
> 
> Could you take a look in the camel-http component?
> I suspect it does not concat the HTTP_PATH and HTTP_URI headers.
> 
> Could be a glitch in there.
> 


Hi,

I think you are right. In the HttpProducer.createMethod() of the camel-http
component, the URI is taken from the HTTP_URI header or the endpoint, but
the HTTP_PATH header is not concatenated.

M.S.
-- 
View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22800487.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Setting a path in message header with Camel-http 2.0M1

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 30, 2009 at 1:51 PM, m.s. <da...@arcor.de> wrote:
>
> I use Camel-http 2.0M1 to send messages to an http endpoint. The URI is
> defined in the endpoint, but I would like to specify the last part of the
> path dynamically in the header.
>
> So I tried to set the header as follows (before I send the message with
> ProducerTemplate.sendBodyAndHeader(...):
>
>        Map <String,Object> header = new HashMap();
>        header.put(HttpConstants.HTTP_METHOD, "POST");
>        header.put(HttpConstants.HTTP_URI,
> "http://localhost:8080/myService");
>        header.put(HttpConstants.HTTP_PATH, "testPath");
>
> But the path is ignored and the message is sent to
> http://localhost:8080/myService (or the URI defined in the endpoint if I
> delete the third line).
>
> Thanks for any hints on what I do wrong,
Hi

Sorry for not getting back to you sooner.

Could you take a look in the camel-http component?
I suspect it does not concat the HTTP_PATH and HTTP_URI headers.

Could be a glitch in there.


>
> M.S.
> --
> View this message in context: http://www.nabble.com/Setting-a-path-in-message-header-with-Camel-http-2.0M1-tp22781504p22781504.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus