Hello Sankar,

HttpClient classes in 4.1.x have a setRedirectStrategy() method that you use
to set with your custom redirect strategy.

hth



On Thu, Dec 9, 2010 at 5:22 AM, sansun08 <[email protected]>wrote:

>
> I am having the same problem. Thanks for your answer. But how can I
> associate
> this custom RedirectStratergy to  the httpclient instance. There are no
> methods available to do that.
>
> Thanks
> Sankar
>
>
> Ryan Smith-10 wrote:
> >
> > 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 <[email protected]> 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: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/POST-response-with-status-302-doesn%27t-redirect-tp30134484p30414709.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to