[#729] Correctly handle urls with empty abs_path in it when issue the websocket handshake

This commit is contained in:
Norman Maurer 2012-11-12 15:33:23 +01:00
parent adee1b4156
commit df575c6cd0
3 changed files with 12 additions and 0 deletions

View File

@ -155,6 +155,10 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
if (path == null || path.length() == 0) {
path = "/";
}
// Format request
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path);
request.addHeader(Names.UPGRADE, Values.WEBSOCKET);

View File

@ -128,6 +128,10 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
if (path == null || path.length() == 0) {
path = "/";
}
// Get 16 bit nonce and base 64 encode it
ChannelBuffer nonce = ChannelBuffers.wrappedBuffer(WebSocketUtil.randomBytes(16));
String key = WebSocketUtil.base64(nonce);

View File

@ -127,6 +127,10 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
if (path == null || path.length() == 0) {
path = "/";
}
// Get 16 bit nonce and base 64 encode it
ChannelBuffer nonce = ChannelBuffers.wrappedBuffer(WebSocketUtil.randomBytes(16));
String key = WebSocketUtil.base64(nonce);