Skip to content

Commit a7f4db3

Browse files
committed
HTTPCLIENT-2355: Reset protocol version in the execution context upon 200 response to CONNECT request
1 parent f7f8069 commit a7f4db3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ public void consumeResponse(final HttpResponse response,
464464
state.tunnelRefused = true;
465465
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));
466466
} else if (status == HttpStatus.SC_OK) {
467+
clientContext.setProtocolVersion(null);
467468
asyncExecCallback.completed();
468469
} else {
469470
throw new HttpException("Unexpected response to CONNECT request: " + new StatusLine(response));

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ private ClassicHttpResponse createTunnelToTarget(
286286
}
287287

288288
final int status = response.getCode();
289-
if (status != HttpStatus.SC_OK) {
289+
if (status == HttpStatus.SC_OK) {
290+
context.setProtocolVersion(null);
291+
} else {
290292
final HttpEntity entity = response.getEntity();
291293
if (entity != null) {
292294
response.setEntity(new ByteArrayEntity(

0 commit comments

Comments
 (0)