Automatic redirection with Apache HttpClient

I am using apache HttpClient with my Android 4.2 app. I have a requirement to support automatic request redirection. I am setting the auto-redirect flag in the request like this:

HttpClientParams.setRedirecting(this.request.getParams(), isAutoRedirectEnabled);

      

Requests redirect fine as long as the request is a simple GET. When I send a POST request with a specific payload, the first request is sent as a POST, but when those requests are redirected, the auto-redirect logic sends a GET request to the redirected url.

I tried setting up the HttpRedirectHandler to DefaultHttpClient and handling the retry manually, but this is a very hacky way to do it and I already found problems with it. Is there another way?

+3


source to share





All Articles