hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: How to get POST redirects into a GET request.
Date Wed, 13 Oct 2010 14:13:12 GMT
On Wed, 2010-10-13 at 00:09 -0400, Ryan Smith wrote:
> Ok, ill try to answer my own question.  Yes, its against the the RFCs,
> 
>  http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
> 
> Note: RFC 1945 and RFC 2068 specify that the client is not allowed
>       to change the method on the redirected request
> 
> So I just overrode the isRedirect() method and returned True when a POST and
> a redirect were happening and everything works fine.
> 
> -Ryan
> 

Yep, custom RedirectStrategy implementations can relax pretty much any
restriction on redirect handling imposed by the HTTP spec.

Cheers

Oleg

> 
> On Tue, Oct 12, 2010 at 11:47 PM, Ryan Smith <ryan.justin.smith@gmail.com>wrote:
> 
> > Hello,
> >
> > I am using HttpClient 4.1-alpha2 and I am coming across a web server that
> > takes a POST method request, but sends back a 302 temp redirect.
> >
> > After checking the DefaultRedirectStrategy code, line 83,  I noticed that
> > POSTs wont redirect. (probably breaks an RFC?)
> >
> >         switch (statusCode) {
> >         case HttpStatus.SC_MOVED_TEMPORARILY:
> >             return (method.equalsIgnoreCase(HttpGet.METHOD_NAME)
> >                 || method.equalsIgnoreCase(HttpHead.METHOD_NAME)) &&
> > locationHeader != null;
> >
> > So since Firefox, MSIE, etc take redirects from a POST and do a GET on the
> > redirected location uri, how would I go about doing that in HttpClient?  I
> > figured I'd ask here before hacking & patching.
> >
> > Thank you.
> >
> > -Ryan
> >
> >
> >



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


Mime
View raw message