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 Darshak Thakore <d....@cablelabs.com> on 2007/03/24 23:29:40 UTC

Problem using strict mode in httpclient

Hi,
I am trying to use the httpclient with a postmethod for performing some
action on a server that I have. Now if the action succeeds the server
usually responds with a 302 message with a TEMPORARY_REDIRECT and the
default behavior of the httpclient is to automatically send a GET to the
new url. I want the httpclient to not do this as I want to
programmatically read the 302 message. I believe according to the RFC,
the client is not supposed to perform a GET without user action but most
clients do. I tried to enable the 'makestrict()' method both on the
httpclient and the postmethod but it still does the same thing. How do I
stop the postmethod and/or the httpclient from automatically doing the
redirect on a 302.
Any help will be appreciated.

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


Re: Problem using strict mode in httpclient

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2007-03-24 at 16:29 -0600, Darshak Thakore wrote:
> Hi,
> I am trying to use the httpclient with a postmethod for performing some
> action on a server that I have. Now if the action succeeds the server
> usually responds with a 302 message with a TEMPORARY_REDIRECT and the
> default behavior of the httpclient is to automatically send a GET to the
> new url. I want the httpclient to not do this as I want to
> programmatically read the 302 message. I believe according to the RFC,
> the client is not supposed to perform a GET without user action but most
> clients do. I tried to enable the 'makestrict()' method both on the
> httpclient and the postmethod but it still does the same thing. How do I
> stop the postmethod and/or the httpclient from automatically doing the
> redirect on a 302.
> Any help will be appreciated.

Darshak,

HttpMethod#setFollowRedirects() is your friend

Hope this helps

Oleg

> 
> ---------------------------------------------------------------------
> 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