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.

Reply via email to