Skip to content

Commit 5492fe8

Browse files
committed
Fix connectionHeader computation
1 parent f8f87ee commit 5492fe8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

client/src/main/java/org/asynchttpclient/netty/request/NettyRequestFactory.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public NettyRequest newNettyRequest(Request request, boolean forceConnect, Proxy
201201
.set(SEC_WEBSOCKET_VERSION, "13");
202202

203203
} else if (!headers.contains(CONNECTION)) {
204-
String connectionHeaderValue = connectionHeader(allowConnectionPooling, httpVersion == HttpVersion.HTTP_1_1);
204+
String connectionHeaderValue = connectionHeader(allowConnectionPooling, httpVersion);
205205
if (connectionHeaderValue != null)
206206
headers.set(CONNECTION, connectionHeaderValue);
207207
}
@@ -243,12 +243,12 @@ else if (proxyServer != null)
243243
}
244244
}
245245

246-
private String connectionHeader(boolean allowConnectionPooling, boolean http11) {
247-
if (allowConnectionPooling)
248-
return HttpHeaders.Values.KEEP_ALIVE;
249-
else if (http11)
250-
return HttpHeaders.Values.CLOSE;
251-
else
252-
return null;
246+
private String connectionHeader(boolean allowConnectionPooling, HttpVersion httpVersion) {
247+
248+
if (httpVersion.isKeepAliveDefault()) {
249+
return allowConnectionPooling ? null : HttpHeaders.Values.CLOSE;
250+
} else {
251+
return allowConnectionPooling ? HttpHeaders.Values.KEEP_ALIVE : null;
252+
}
253253
}
254254
}

0 commit comments

Comments
 (0)