You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Matthew S. Ring" <ma...@wamu.net> on 2003/03/17 23:51:19 UTC

redirects not allowed for PostMethod

Hi,

I just started using the latest version of the HTTPClient to screen-scrape
from Rational Clear Quest. Unfortunately, CQ expects POSTed requests and
responds with a redirect. IE and Mozilla-based browsers seem OK with that,
but the HTTPClient refuses to follow redirects after a POST, due to stated
conflicts with RFC 2616. Is this stringency really neccesary? Selfishly, it
would be nice if I could just turn off this bit of compliance checking with
a boolean flag. Opinions?

Thanks.

-Matthew Ring


Re: redirects not allowed for PostMethod

Posted by Oleg Kalnichevski <o....@dplanet.ch>.
Hi Matthew

We have had quite a bit of argument regarding automatic POST redirects a
while ago

http://www.mail-archive.com/commons-httpclient-dev%40jakarta.apache.org/msg01116.html

If you disagree with the conclusion we arrived at, feel free to file a
bug report. We would not mind providing this option in the future. I
just personally think it's unreasonable, but, again, there are ways of
seeing and not seeing

Cheers

Oleg


On Mon, 2003-03-17 at 23:51, Matthew S. Ring wrote:
> Hi,
> 
> I just started using the latest version of the HTTPClient to screen-scrape
> from Rational Clear Quest. Unfortunately, CQ expects POSTed requests and
> responds with a redirect. IE and Mozilla-based browsers seem OK with that,
> but the HTTPClient refuses to follow redirects after a POST, due to stated
> conflicts with RFC 2616. Is this stringency really neccesary? Selfishly, it
> would be nice if I could just turn off this bit of compliance checking with
> a boolean flag. Opinions?
> 
> Thanks.
> 
> -Matthew Ring
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


Re: redirects not allowed for PostMethod

Posted by David Kavanagh <da...@dotech.com>.
Matt,
I went through the same thing a week or two ago. Thing is, what method 
should the PostMethod use for the redirect? You need to capture the 
result and issue a GET using the Location response header attribute.

David

Matthew S. Ring wrote:

>Hi,
>
>I just started using the latest version of the HTTPClient to screen-scrape
>from Rational Clear Quest. Unfortunately, CQ expects POSTed requests and
>responds with a redirect. IE and Mozilla-based browsers seem OK with that,
>but the HTTPClient refuses to follow redirects after a POST, due to stated
>conflicts with RFC 2616. Is this stringency really neccesary? Selfishly, it
>would be nice if I could just turn off this bit of compliance checking with
>a boolean flag. Opinions?
>
>Thanks.
>
>-Matthew Ring
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>  
>



Re: redirects not allowed for PostMethod

Posted by Ortwin Glück <or...@nose.ch>.
Jeffrey Dever wrote:
> I'd say that a post redirect converted to a get is good behaviour to add 
> as part of the redirect overhaul as discussed for httpclient 3.0

The problem of this scenario is:
- you tell HttpClient to execute a POST
- it is redirected and executes a GET automatically
- but the application only has a reference to the PostMethod instance 
and not to the GetMethod instance. So you would not be able get *any* 
data back (not even a status code)!


Re: redirects not allowed for PostMethod

Posted by Mike Moran <mi...@mac.com>.
On Tuesday, March 18, 2003, at 07:16 AM, Jeffrey Dever wrote:

> I'd say that a post redirect converted to a get is good behaviour to 
> add as part of the redirect overhaul as discussed for httpclient 3.0

I would say such behaviour is fine as long as it can be turned off on a 
per request basis.

-- 
Mike


Re: redirects not allowed for PostMethod

Posted by Jeffrey Dever <js...@sympatico.ca>.
I'd say that a post redirect converted to a get is good behaviour to add 
as part of the redirect overhaul as discussed for httpclient 3.0

Tom Samplonius wrote:

>On Mon, 17 Mar 2003, Matthew S. Ring wrote:
>
>...
>  
>
>>conflicts with RFC 2616. Is this stringency really neccesary? Selfishly, it
>>    
>>
>...
>
>  I think there is some confusion about RFC2616 and redirected POSTs.
>RFC2616 says that POSTs should not be redirected, and no one really does
>that.  All current web browsers handle a redirect to a POST, but GETting
>the the new location.  In effect, the POST is not really redirected at
>all, but the server is just sending you to a new location after receiving
>your POST.
>
>  I think httpclient should mimic web browser behaviour, as it is
>universal.  However, it is not hard to do it yourself, but read the new
>location, and GET it.  So it is not vital for httpclient to do this for
>you.  And automatic following of redirects is not really complete in
>httpclient anyhow, so you should always be ready to follow redirects if
>necessary.
>
>
>Tom
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>
>
>  
>



Re: redirects not allowed for PostMethod

Posted by Tom Samplonius <to...@sdf.com>.
On Mon, 17 Mar 2003, Matthew S. Ring wrote:

...
> conflicts with RFC 2616. Is this stringency really neccesary? Selfishly, it
...

  I think there is some confusion about RFC2616 and redirected POSTs.
RFC2616 says that POSTs should not be redirected, and no one really does
that.  All current web browsers handle a redirect to a POST, but GETting
the the new location.  In effect, the POST is not really redirected at
all, but the server is just sending you to a new location after receiving
your POST.

  I think httpclient should mimic web browser behaviour, as it is
universal.  However, it is not hard to do it yourself, but read the new
location, and GET it.  So it is not vital for httpclient to do this for
you.  And automatic following of redirects is not really complete in
httpclient anyhow, so you should always be ready to follow redirects if
necessary.


Tom