@@ -69,9 +69,11 @@ private ConnectionInfo parseForwardedInfo(ConnectionInfo connectionInfo, String
6969 if (protoMatcher .find ()) {
7070 connectionInfo = connectionInfo .withScheme (protoMatcher .group (1 ).trim ());
7171 }
72- int port = connectionInfo .getScheme ().equalsIgnoreCase ("https" ) ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT ;
7372 Matcher hostMatcher = FORWARDED_HOST_PATTERN .matcher (forwarded );
7473 if (hostMatcher .find ()) {
74+ String scheme = connectionInfo .getScheme ();
75+ int port = scheme .equalsIgnoreCase ("https" ) || scheme .equalsIgnoreCase ("wss" ) ?
76+ DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT ;
7577 connectionInfo = connectionInfo .withHostAddress (
7678 AddressUtils .parseAddress (hostMatcher .group (1 ), port , DEFAULT_FORWARDED_HEADER_VALIDATION ));
7779 }
@@ -96,7 +98,9 @@ private ConnectionInfo parseXForwardedInfo(ConnectionInfo connectionInfo, HttpRe
9698 }
9799 String hostHeader = request .headers ().get (X_FORWARDED_HOST_HEADER );
98100 if (hostHeader != null ) {
99- int port = connectionInfo .getScheme ().equalsIgnoreCase ("https" ) ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT ;
101+ String scheme = connectionInfo .getScheme ();
102+ int port = scheme .equalsIgnoreCase ("https" ) || scheme .equalsIgnoreCase ("wss" ) ?
103+ DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT ;
100104 connectionInfo = connectionInfo .withHostAddress (
101105 AddressUtils .parseAddress (hostHeader .split ("," , 2 )[0 ].trim (), port , DEFAULT_FORWARDED_HEADER_VALIDATION ));
102106 String portHeader = request .headers ().get (X_FORWARDED_PORT_HEADER );
0 commit comments