Skip to content

Commit

Permalink
HTTPCLIENT-2355, regression: Reset protocol version in the execution …
Browse files Browse the repository at this point in the history
…context upon 200 response to CONNECT request
  • Loading branch information
ok2c committed Jan 20, 2025
1 parent f7f8069 commit 8958b36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ public void consumeResponse(final HttpResponse response,
state.tunnelRefused = true;
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));
} else if (status == HttpStatus.SC_OK) {
clientContext.setProtocolVersion(null);
asyncExecCallback.completed();
} else {
throw new HttpException("Unexpected response to CONNECT request: " + new StatusLine(response));
Expand Down Expand Up @@ -552,7 +553,6 @@ private void proceedConnected(
final HttpClientContext clientContext = scope.clientContext;
final EndpointInfo endpointInfo = execRuntime.getEndpointInfo();
if (endpointInfo != null) {
clientContext.setProtocolVersion(endpointInfo.getProtocol());
clientContext.setSSLSession(endpointInfo.getSslSession());
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public ClassicHttpResponse execute(
}
final EndpointInfo endpointInfo = execRuntime.getEndpointInfo();
if (endpointInfo != null) {
context.setProtocolVersion(endpointInfo.getProtocol());
context.setSSLSession(endpointInfo.getSslSession());
}
return chain.proceed(request, scope);
Expand Down Expand Up @@ -286,7 +285,9 @@ private ClassicHttpResponse createTunnelToTarget(
}

final int status = response.getCode();
if (status != HttpStatus.SC_OK) {
if (status == HttpStatus.SC_OK) {
context.setProtocolVersion(null);
} else {
final HttpEntity entity = response.getEntity();
if (entity != null) {
response.setEntity(new ByteArrayEntity(
Expand Down

0 comments on commit 8958b36

Please sign in to comment.