hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Smith <ryan.justin.sm...@gmail.com>
Subject Re: POST response with status 302 doesn't redirect
Date Thu, 04 Nov 2010 19:26:14 GMT
DefaultRedirectStrategy is in 4.1-alpha2.  Youre using 4.0.3 so it has
RedirectHandler.  Anywho you dont need to override the getLocationUrl().
You want to override the isRedirectRequested()

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/client/DefaultRedirectHandler.html

hth

On Thu, Nov 4, 2010 at 3:11 PM, motital74 <motital@gmail.com> wrote:

>
> Ryan, thanks again
>
> I can find the DefaultRedirectStrategy as part of the GA.
>
> I did implement the handler:
> public URI getLocationURI(HttpResponse httpResponse, HttpContext
> httpContext) throws ProtocolException {
>                System.out.println("=======================getLocationURI");
>                Header[] headers = httpResponse.getHeaders("Location");
>                if (headers != null && headers.length > 0) {
>                    try {
>                        System.out.println(""==============getLocationURI
> return" + headers[0].getValue());
>                        return new URI(headers[0].getValue());
>                    } catch (URISyntaxException e) {
>                        e.printStackTrace();
>                    }
>                }
>                System.out.println("=======================getLocationURI
> return null");
>                return null;
>            }
>
> In my case i see the return log with the correct URI
>
>
> Ryan Smith-10 wrote:
> >
> > I am using 4.1-alpha2, in this version, you extend
> DefaultRedirectStrategy
> > and override the method isRedirected().  Inside that method, check for a
> > post method and a 302 or 301 and return true if so.  I use something like
> > this:
> >
> >   boolean isRedirect = super.isRedirected(request, response, context);
> >   if (!isRedirect) {
> >         //  Then check for POST and 302 or 301.
> >
> > Maybe post your code?
> >
>
>
> --
> View this message in context:
> http://old.nabble.com/POST-response-with-status-302-doesn%27t-redirect-tp30134484p30135246.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message