diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java index 03a770d28..92081e919 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java @@ -142,11 +142,16 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler { switch (statusCode) { case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_TEMPORARILY: - case HttpStatus.SC_SEE_OTHER: if (Method.POST.isSame(request.getMethod())) { state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri); state.currentEntityProducer = null; } + break; + case HttpStatus.SC_SEE_OTHER: + if (!Method.GET.isSame(request.getMethod()) && !Method.HEAD.isSame(request.getMethod())) { + state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri); + state.currentEntityProducer = null; + } } if (state.currentRequest == null) { state.currentRequest = new BasicHttpRequest(request.getMethod(), redirectUri); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java index d6ec2f5fa..bf55aec75 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java @@ -145,10 +145,14 @@ public final class RedirectExec implements ExecChainHandler { switch (statusCode) { case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_TEMPORARILY: - case HttpStatus.SC_SEE_OTHER: if (Method.POST.isSame(request.getMethod())) { redirect = new HttpGet(redirectUri); } + break; + case HttpStatus.SC_SEE_OTHER: + if (!Method.GET.isSame(request.getMethod()) && !Method.HEAD.isSame(request.getMethod())) { + redirect = new HttpGet(redirectUri); + } } if (redirect == null) { redirect = new BasicClassicHttpRequest(originalRequest.getMethod(), redirectUri);