Adds port to the host header value in WebSocket client handshake.
Due to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23 the port should be added if it differs from the default port. To simplify the code we just always add the port. Backported from 82176bed76ddca1506a3627a7804d51f00637186
This commit is contained in:
parent
0ec12dcc60
commit
6aa4d147d8
@ -146,13 +146,13 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format request
|
// Format request
|
||||||
|
int wsPort = wsURL.getPort();
|
||||||
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
|
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
|
||||||
request.addHeader(Names.UPGRADE, Values.WEBSOCKET.toLowerCase());
|
request.addHeader(Names.UPGRADE, Values.WEBSOCKET.toLowerCase());
|
||||||
request.addHeader(Names.CONNECTION, Values.UPGRADE);
|
request.addHeader(Names.CONNECTION, Values.UPGRADE);
|
||||||
request.addHeader(Names.SEC_WEBSOCKET_KEY, key);
|
request.addHeader(Names.SEC_WEBSOCKET_KEY, key);
|
||||||
request.addHeader(Names.HOST, wsURL.getHost());
|
request.addHeader(Names.HOST, wsURL.getHost() + ':' + wsPort);
|
||||||
|
|
||||||
int wsPort = wsURL.getPort();
|
|
||||||
String originValue = "http://" + wsURL.getHost();
|
String originValue = "http://" + wsURL.getHost();
|
||||||
if (wsPort != 80 && wsPort != 443) {
|
if (wsPort != 80 && wsPort != 443) {
|
||||||
// if the port is not standard (80/443) its needed to add the port to the header.
|
// if the port is not standard (80/443) its needed to add the port to the header.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user