File tree 2 files changed +11
-1
lines changed
main/java/org/apache/hc/client5/http/protocol
test/java/org/apache/hc/client5/http/protocol 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ public void process(
67
67
final RequestConfig requestConfig = clientContext .getRequestConfigOrDefault ();
68
68
if (requestConfig .isProtocolUpgradeEnabled ()) {
69
69
final ProtocolVersion version = request .getVersion () != null ? request .getVersion () : clientContext .getProtocolVersion ();
70
- if (!request .containsHeader (HttpHeaders .UPGRADE ) && version .getMajor () == 1 && version .getMinor () >= 1 ) {
70
+ if (!request .containsHeader (HttpHeaders .UPGRADE ) &&
71
+ !request .containsHeader (HttpHeaders .CONNECTION ) &&
72
+ version .getMajor () == 1 && version .getMinor () >= 1 ) {
71
73
if (LOG .isDebugEnabled ()) {
72
74
LOG .debug ("Connection is upgradable: protocol version = {}" , version );
73
75
}
Original file line number Diff line number Diff line change @@ -109,6 +109,14 @@ void testDoUpgradeIfAlreadyTLS() throws Exception {
109
109
Assertions .assertFalse (get .containsHeader (HttpHeaders .UPGRADE ));
110
110
}
111
111
112
+ @ Test
113
+ void testDoUpgradeIfConnectionHeaderPresent () throws Exception {
114
+ final HttpRequest get = new BasicHttpRequest ("GET" , "/" );
115
+ get .addHeader (HttpHeaders .CONNECTION , "keep-alive" );
116
+ interceptor .process (get , null , context );
117
+ Assertions .assertFalse (get .containsHeader (HttpHeaders .UPGRADE ));
118
+ }
119
+
112
120
@ Test
113
121
void testDoUpgradeNonSafeMethodsOrTrace () throws Exception {
114
122
final HttpRequest post = new BasicHttpRequest ("POST" , "/" );
You can’t perform that action at this time.
0 commit comments