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 2022/01/13 14:42:39 UTC

[httpcomponents-client] branch master updated: HTTPCLIENT-2195, regression: classic ConnectExec incorrectly discards the proxy response body even if the request cannot be executed and the response is final

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 3ee994b  HTTPCLIENT-2195, regression: classic ConnectExec incorrectly discards the proxy response body even if the request cannot be executed and the response is final
3ee994b is described below

commit 3ee994b25c9974f9de16c71506b15ea1991febf5
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Jan 12 11:02:53 2022 +0100

    HTTPCLIENT-2195, regression: classic ConnectExec incorrectly discards the proxy response body even if the request cannot be executed and the response is final
---
 .../hc/client5/http/impl/classic/ConnectExec.java   | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
index 45c0c5e..df0eb4b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java
@@ -238,17 +238,6 @@ public final class ConnectExec implements ExecChainHandler {
                 throw new HttpException("Unexpected response to CONNECT request: " + new StatusLine(response));
             }
 
-            if (this.reuseStrategy.keepAlive(connect, response, context)) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("{} connection kept alive", exchangeId);
-                }
-                // Consume response content
-                final HttpEntity entity = response.getEntity();
-                EntityUtils.consume(entity);
-            } else {
-                execRuntime.disconnectEndpoint();
-            }
-
             if (config.isAuthenticationEnabled()) {
                 final boolean proxyAuthRequested = authenticator.isChallenged(proxy, ChallengeType.PROXY, response, proxyAuthExchange, context);
 
@@ -269,6 +258,16 @@ public final class ConnectExec implements ExecChainHandler {
                     }
                     if (updated) {
                         // Retry request
+                        if (this.reuseStrategy.keepAlive(connect, response, context)) {
+                            if (LOG.isDebugEnabled()) {
+                                LOG.debug("{} connection kept alive", exchangeId);
+                            }
+                            // Consume response content
+                            final HttpEntity entity = response.getEntity();
+                            EntityUtils.consume(entity);
+                        } else {
+                            execRuntime.disconnectEndpoint();
+                        }
                         response = null;
                     }
                 }