Add port to Origin HTTP Header if the port is non default (80/443).
See #262
This commit is contained in:
parent
864167270d
commit
347772a1e9
@ -138,7 +138,15 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
request.addHeader(Names.UPGRADE, Values.WEBSOCKET);
|
||||
request.addHeader(Names.CONNECTION, Values.UPGRADE);
|
||||
request.addHeader(Names.HOST, wsURL.getHost());
|
||||
request.addHeader(Names.ORIGIN, "http://" + wsURL.getHost());
|
||||
|
||||
int wsPort = wsURL.getPort();
|
||||
String originValue = "http://" + wsURL.getHost();
|
||||
if (wsPort != 80 && wsPort != 443) {
|
||||
// if the port is not standard (80/443) its needed to add the port to the header.
|
||||
// See http://tools.ietf.org/html/rfc6454#section-6.2
|
||||
originValue = originValue + ":" + wsPort;
|
||||
}
|
||||
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1);
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2);
|
||||
if (getExpectedSubprotocol() != null && !getExpectedSubprotocol().equals("")) {
|
||||
|
@ -122,7 +122,15 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
request.addHeader(Names.CONNECTION, Values.UPGRADE);
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY, key);
|
||||
request.addHeader(Names.HOST, wsURL.getHost());
|
||||
request.addHeader(Names.ORIGIN, "http://" + wsURL.getHost());
|
||||
|
||||
int wsPort = wsURL.getPort();
|
||||
String originValue = "http://" + wsURL.getHost();
|
||||
if (wsPort != 80 && wsPort != 443) {
|
||||
// if the port is not standard (80/443) its needed to add the port to the header.
|
||||
// See http://tools.ietf.org/html/rfc6454#section-6.2
|
||||
originValue = originValue + ":" + wsPort;
|
||||
}
|
||||
|
||||
if (protocol != null && !protocol.equals("")) {
|
||||
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, protocol);
|
||||
}
|
||||
|
@ -122,7 +122,15 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
request.addHeader(Names.CONNECTION, Values.UPGRADE);
|
||||
request.addHeader(Names.SEC_WEBSOCKET_KEY, key);
|
||||
request.addHeader(Names.HOST, wsURL.getHost());
|
||||
request.addHeader(Names.ORIGIN, "http://" + wsURL.getHost());
|
||||
|
||||
int wsPort = wsURL.getPort();
|
||||
String originValue = "http://" + wsURL.getHost();
|
||||
if (wsPort != 80 && wsPort != 443) {
|
||||
// if the port is not standard (80/443) its needed to add the port to the header.
|
||||
// See http://tools.ietf.org/html/rfc6454#section-6.2
|
||||
originValue = originValue + ":" + wsPort;
|
||||
}
|
||||
|
||||
if (protocol != null && !protocol.equals("")) {
|
||||
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, protocol);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user