HTTPCLIENT-2195, regression: classic ConnectExec incorrectly discards the proxy response body even if the request cannot be executed and the response is final

This commit is contained in:
Oleg Kalnichevski 2022-01-12 11:02:53 +01:00
parent 9e876e7ff0
commit 3ee994b25c
1 changed files with 10 additions and 11 deletions

View File

@ -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;
}
}