File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ public void process(
6767 final RequestConfig requestConfig = clientContext .getRequestConfigOrDefault ();
6868 if (requestConfig .isProtocolUpgradeEnabled ()) {
6969 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 ) {
7173 if (LOG .isDebugEnabled ()) {
7274 LOG .debug ("Connection is upgradable: protocol version = {}" , version );
7375 }
Original file line number Diff line number Diff line change @@ -109,6 +109,14 @@ void testDoUpgradeIfAlreadyTLS() throws Exception {
109109 Assertions .assertFalse (get .containsHeader (HttpHeaders .UPGRADE ));
110110 }
111111
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+
112120 @ Test
113121 void testDoUpgradeNonSafeMethodsOrTrace () throws Exception {
114122 final HttpRequest post = new BasicHttpRequest ("POST" , "/" );
You can’t perform that action at this time.
0 commit comments