You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/02/17 13:56:41 UTC

[httpcomponents-client] branch master updated: HTTPCLIENT-2051: Change POST to GET for 301, 302 and 303 redirects. Other unsafe methods to be redirected as is.

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 53e1725  HTTPCLIENT-2051: Change POST to GET for 301, 302 and 303 redirects. Other unsafe methods to be redirected as is.
53e1725 is described below

commit 53e172553df2dbb1029c36f9e6df1c54a8f02157
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Feb 17 13:38:43 2020 +0100

    HTTPCLIENT-2051: Change POST to GET for 301, 302 and 303 redirects. Other unsafe methods to be redirected as is.
---
 .../java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java   | 2 +-
 .../main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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 ef7a138..03a770d 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
@@ -143,7 +143,7 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
                         case HttpStatus.SC_MOVED_PERMANENTLY:
                         case HttpStatus.SC_MOVED_TEMPORARILY:
                         case HttpStatus.SC_SEE_OTHER:
-                            if (!Method.isSafe(request.getMethod())) {
+                            if (Method.POST.isSame(request.getMethod())) {
                                 state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri);
                                 state.currentEntityProducer = null;
                             }
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 bdd3219..d6ec2f5 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
@@ -146,7 +146,7 @@ public final class RedirectExec implements ExecChainHandler {
                         case HttpStatus.SC_MOVED_PERMANENTLY:
                         case HttpStatus.SC_MOVED_TEMPORARILY:
                         case HttpStatus.SC_SEE_OTHER:
-                            if (!Method.isSafe(request.getMethod())) {
+                            if (Method.POST.isSame(request.getMethod())) {
                                 redirect = new HttpGet(redirectUri);
                             }
                     }