WebSocketClientHandshaker.rawPath(URI) should use the raw query

Motivation:

If the wsURL contains an encoded query, it will be decoded when generating the raw path.  For example if the wsURL is http://test.org/path?a=1%3A5, the returned raw path would be /path?a=1:5

Modifications:

Use wsURL.getRawQuery() rather than wsURL.getQuery()

Result:

rawPath will now return /path?a=1%3A5
This commit is contained in:
Adrian Gonzalez 2016-11-09 16:37:51 -05:00 committed by Norman Maurer
parent 75728faf9b
commit baac352f74
2 changed files with 13 additions and 1 deletions

View File

@ -434,7 +434,7 @@ public abstract class WebSocketClientHandshaker {
*/
static String rawPath(URI wsURL) {
String path = wsURL.getRawPath();
String query = wsURL.getQuery();
String query = wsURL.getRawQuery();
if (query != null && !query.isEmpty()) {
path = path + '?' + query;
}

View File

@ -52,6 +52,18 @@ public abstract class WebSocketClientHandshakerTest {
}
}
@Test
public void testRawPathWithQuery() {
URI uri = URI.create("ws://localhost:9999/path%20with%20ws?a=b%20c");
WebSocketClientHandshaker handshaker = newHandshaker(uri);
FullHttpRequest request = handshaker.newHandshakeRequest();
try {
assertEquals("/path%20with%20ws?a=b%20c", request.uri());
} finally {
request.release();
}
}
@Test(timeout = 3000)
public void testHttpResponseAndFrameInSameBuffer() {
testHttpResponseAndFrameInSameBuffer(false);