Hello everyone,

At the beginning, I had something like that :
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(SOME_URL);
HttpResponse postResponse = httpClient.execute(httpPost);

It turns out that I got a 301 Moved permanently.

So I made the following modifications, either:
- httpClient.setRedirectStrategy(new LaxRedirectStrategy());
- or httpClient.setRedirectStrategy(new DefaultRedirectStrategy());
- or              httpClient.setRedirectStrategy(new DefaultRedirectStrategy() {
                  @Override
                  public boolean isRedirected(HttpRequest request, HttpResponse 
response, HttpContext context) {
                        boolean isRedirected = false;
                        try {
                              isRedirected = super.isRedirected(request, 
response, context);
                        } catch (ProtocolException e) {
                              fail("Unable to set a redirect strategy, reason: 
" + e.getMessage());
                        }
                        
                        if (!isRedirected) {
                              int responseCode = 
response.getStatusLine().getStatusCode();
                              if (responseCode == 301 || responseCode == 302) {
                                    return true;
                              }
                        }
                        return false;
                  }
            });
- or the same than above with new LaxRedirectStrategy

Each time, after receiving a 301, the client sent a GET request instead of my 
initial HTTP request, which is a POST one as you can see, to the new location.
Any advice ? sample ? 
Or is it an issue ?

Best Regards.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to