You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tim R J Langford <ti...@multicom.co.uk> on 2005/08/05 12:27:22 UTC

HttpMethod.setFollowRedirects(bool) does not work for POST methods ???

Hello All,

I am newbie to both working with HTTP directly and HttpClient, so excuse 
me if I am being naieve.

I have a problem with redirects and HttpClient. I have a configuration 
object in my code that is used to
configure my HttpMethod that subsequently gets excecuted. I have steped 
through this code in a debugger and
appears that if I use the HttpMethod.setFollowRedirects(bool) method 
when the method type is a POST then the
underlying boolean is not set as I wish, but when the underlying method 
type is a GET, then it is correctly set.

I then also have a subsequent problem that HttpClient informs me the 
redirect for the POST could not be followed (possibly because redirects 
is false). eg:


MessageType = GET
Follow Redirects before configuration = false
Follow Redirects after configuration = true
<Correctly Redirects>

MessageType = POST
Follow Redirects before configuration = false
Follow Redirects after configuration = false
Aug 5, 2005 11:05:36 AM org.apache.commons.httpclient.HttpMethodBase 
processRedirectResponse
INFO: Redirect requested but followRedirects is disabled


Am I completely off the track here> The HTTP spec seems to say POST 
responses can redirect. Is there a deliberate reason why my setting on a 
POST method has no effect?

I would appreciate any help or info available on this issue. Sorry if I 
am an idiot!

Thankyou for your time,

Tim

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: HttpMethod.setFollowRedirects(bool) does not work for POST methods ???

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Tim,

> So I presume that I must catch this status code and perform the 
> redirection manually myself when it occurs?
> I think I saw a bit on the website about that, so I will check it out.

Yes. It's not that tricky. And you can use a GET request for the
redirect, if that is what the server expects.

> Sorry for wasting your time, and thanks for your help,
> 
Never mind, you're welcome. That's what a user mailing list is for!

cheers,
  Roland
 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: HttpMethod.setFollowRedirects(bool) does not work for POST methods ???

Posted by Tim R J Langford <ti...@multicom.co.uk>.
Hi Roland,

Thanks for you reply and information. I see you are correct, so I guess 
I must improve my spec reading skills.

So I presume that I must catch this status code and perform the 
redirection manually myself when it occurs?
I think I saw a bit on the website about that, so I will check it out.

Sorry for wasting your time, and thanks for your help,

Tim



>Hi Tim,
>
>  
>
>>The HTTP spec seems to say POST 
>>responses can redirect. Is there a deliberate reason why my setting on a 
>>    
>>
>
>  
>
>>POST method has no effect?
>>    
>>
>
>It says POST methods MUST NOT redirect without user interaction.
>See RFC 2616, section 10.3.3, page 62. Since HttpClient does not
>implement a user front-end, we can't redirect automatically.
>
>cheers,
>  Roland
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: HttpMethod.setFollowRedirects(bool) does not work for POST methods ???

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Tim,

> The HTTP spec seems to say POST 
> responses can redirect. Is there a deliberate reason why my setting on a 

> POST method has no effect?

It says POST methods MUST NOT redirect without user interaction.
See RFC 2616, section 10.3.3, page 62. Since HttpClient does not
implement a user front-end, we can't redirect automatically.

cheers,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org