You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "abhijit.kulkarni" <ab...@globalcharge.com> on 2013/10/18 18:44:02 UTC

Camel Restlet and HTTP 302

Hello, 

I have a route in camel which uses restlet component to receive GET requests
from the client (Android App). 
As part of this request, there are some query parameters I receive and based
on one of the parameter value I have to return different HTTP statuses back
to the service client. 
e.g. if the param value is 'A' then I return HTTP 200 with session Id set in
the body, and this works fine with the following (following is pseudocode in
Spring DSL and have omitted few sections irrelevant to this question). 
<route id="xyz">
   <from
uri="restlet:/authenticate/authCallback/{sessionID}?restletMethods=GET"/>
    .......
   <choice>
      <when>
            
           <setBody>
			<simple>${header.sessionID}</simple>
	   </setBody> 
       </when>
   </choice> 
    ...... 
 </route> 

I want to return HTTP 302 if the param value is 'B' so I have added another
<when> in the choice element as below - 
<when>
    
    <setHeader headerName="CamelHttpResponseCode">
            <constant>302</constant>        
    </setHeader> 
    <setHeader headerName="Location">
           
<constant>http://host:port/another_URL_where_client_must_redirect</constant>        
    </setHeader> 
</when> 

Now coming to a problem area - When client (android app) calls this rest
service with param = 'B', it receives back the HTTP status as 302 but is
unable to redirect because it is unable to find the URL to redirect to.
After capturing the HTTP response in debug mode and printing the headers
received in the Android App, I realized that the 'Location' from the headers
list is missing (So obviously the Android App couldn't perform the
redirect).

Am I doing something wrong ?  Am I setting the Location header correctly ? 

Camel Exchange class has various HTTP related constants, but did not find
any constant to be used to set the redirect url as a location in header. I
was expecting something similar to CamelHttpResponseCode for redirect
location such as CamelHttpResponseRedirectLocation or something like that :) 

Please help me .... 

Abhijit Kulkarni.  





--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-and-HTTP-302-tp5741853.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet and HTTP 302

Posted by "abhijit.kulkarni" <ab...@globalcharge.com>.
Thank you very much for this. 

Abhijit Kulkarni 
Senior Developer @ Global Charge 



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-and-HTTP-302-tp5741853p5741961.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel Restlet and HTTP 302

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I logged a ticket and have a fix in process
https://issues.apache.org/jira/browse/CAMEL-6879


On Sat, Oct 19, 2013 at 3:41 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Yeah seems so this header is not sent back. Feel free to log a JIRA ticket.
>
> On Fri, Oct 18, 2013 at 6:44 PM, abhijit.kulkarni
> <ab...@globalcharge.com> wrote:
>> Hello,
>>
>> I have a route in camel which uses restlet component to receive GET requests
>> from the client (Android App).
>> As part of this request, there are some query parameters I receive and based
>> on one of the parameter value I have to return different HTTP statuses back
>> to the service client.
>> e.g. if the param value is 'A' then I return HTTP 200 with session Id set in
>> the body, and this works fine with the following (following is pseudocode in
>> Spring DSL and have omitted few sections irrelevant to this question).
>> <route id="xyz">
>>    <from
>> uri="restlet:/authenticate/authCallback/{sessionID}?restletMethods=GET"/>
>>     .......
>>    <choice>
>>       <when>
>>
>>            <setBody>
>>                         <simple>${header.sessionID}</simple>
>>            </setBody>
>>        </when>
>>    </choice>
>>     ......
>>  </route>
>>
>> I want to return HTTP 302 if the param value is 'B' so I have added another
>> <when> in the choice element as below -
>> <when>
>>
>>     <setHeader headerName="CamelHttpResponseCode">
>>             <constant>302</constant>
>>     </setHeader>
>>     <setHeader headerName="Location">
>>
>> <constant>http://host:port/another_URL_where_client_must_redirect</constant>
>>     </setHeader>
>> </when>
>>
>> Now coming to a problem area - When client (android app) calls this rest
>> service with param = 'B', it receives back the HTTP status as 302 but is
>> unable to redirect because it is unable to find the URL to redirect to.
>> After capturing the HTTP response in debug mode and printing the headers
>> received in the Android App, I realized that the 'Location' from the headers
>> list is missing (So obviously the Android App couldn't perform the
>> redirect).
>>
>> Am I doing something wrong ?  Am I setting the Location header correctly ?
>>
>> Camel Exchange class has various HTTP related constants, but did not find
>> any constant to be used to set the redirect url as a location in header. I
>> was expecting something similar to CamelHttpResponseCode for redirect
>> location such as CamelHttpResponseRedirectLocation or something like that :)
>>
>> Please help me ....
>>
>> Abhijit Kulkarni.
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-and-HTTP-302-tp5741853.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Restlet and HTTP 302

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah seems so this header is not sent back. Feel free to log a JIRA ticket.

On Fri, Oct 18, 2013 at 6:44 PM, abhijit.kulkarni
<ab...@globalcharge.com> wrote:
> Hello,
>
> I have a route in camel which uses restlet component to receive GET requests
> from the client (Android App).
> As part of this request, there are some query parameters I receive and based
> on one of the parameter value I have to return different HTTP statuses back
> to the service client.
> e.g. if the param value is 'A' then I return HTTP 200 with session Id set in
> the body, and this works fine with the following (following is pseudocode in
> Spring DSL and have omitted few sections irrelevant to this question).
> <route id="xyz">
>    <from
> uri="restlet:/authenticate/authCallback/{sessionID}?restletMethods=GET"/>
>     .......
>    <choice>
>       <when>
>
>            <setBody>
>                         <simple>${header.sessionID}</simple>
>            </setBody>
>        </when>
>    </choice>
>     ......
>  </route>
>
> I want to return HTTP 302 if the param value is 'B' so I have added another
> <when> in the choice element as below -
> <when>
>
>     <setHeader headerName="CamelHttpResponseCode">
>             <constant>302</constant>
>     </setHeader>
>     <setHeader headerName="Location">
>
> <constant>http://host:port/another_URL_where_client_must_redirect</constant>
>     </setHeader>
> </when>
>
> Now coming to a problem area - When client (android app) calls this rest
> service with param = 'B', it receives back the HTTP status as 302 but is
> unable to redirect because it is unable to find the URL to redirect to.
> After capturing the HTTP response in debug mode and printing the headers
> received in the Android App, I realized that the 'Location' from the headers
> list is missing (So obviously the Android App couldn't perform the
> redirect).
>
> Am I doing something wrong ?  Am I setting the Location header correctly ?
>
> Camel Exchange class has various HTTP related constants, but did not find
> any constant to be used to set the redirect url as a location in header. I
> was expecting something similar to CamelHttpResponseCode for redirect
> location such as CamelHttpResponseRedirectLocation or something like that :)
>
> Please help me ....
>
> Abhijit Kulkarni.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-and-HTTP-302-tp5741853.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel Restlet and HTTP 302

Posted by Christian Mueller <ch...@gmail.com>.
Abhijit,

can you please subscribe to the Camel user mailing list as we describe here
[1].
Otherwise all your mails has to be moderate manually by the Camel team so
that your post is also send to our mailing list which most of the Camel team
member are using instead of Nabble. Therefore your post is may
missed/delayed and you don't get an answer in the normal time frame we
answer questions.
Last but not least, it cost time which we cannot spend developing Camel,
answering questions or improving the documentation...

[1] http://camel.apache.org/discussion-forums.html

Thanks in advance,
Christian



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Restlet-and-HTTP-302-tp5741853p5741862.html
Sent from the Camel - Users mailing list archive at Nabble.com.