-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
The` following code in v3.0.5 fails while v3.0.4 works fine:
val client = new DefaultAsyncHttpClient()
client.prepareGet("http://localhost:8080/find")
.addQueryParam("username", "JohnRambo")
.addQueryParam("application", "App")
.execute()
.toCompletableFuture
.thenAccept { response =>
val responseBody = response.getResponseBody
// Check if the response contains the correctly encoded parameters
}
.join()
The exception tells
java.lang.IllegalArgumentException: The URI contain illegal characters: /find?username=JohnRambo&application=App
at io.netty.handler.codec.http.HttpUtil.validateRequestLineTokens(HttpUtil.java:90)
at io.netty.handler.codec.http.DefaultHttpRequest.<init>(DefaultHttpRequest.java:95)
at io.netty.handler.codec.http.DefaultFullHttpRequest.<init>(DefaultFullHttpRequest.java:103)
at io.netty.handler.codec.http.DefaultFullHttpRequest.<init>(DefaultFullHttpRequest.java:95)
at io.netty.handler.codec.http.DefaultFullHttpRequest.<init>(DefaultFullHttpRequest.java:87)
at io.netty.handler.codec.http.DefaultFullHttpRequest.<init>(DefaultFullHttpRequest.java:50)
at org.asynchttpclient.netty.request.NettyRequestFactory.newNettyRequest(NettyRequestFactory.java:151)
at org.asynchttpclient.netty.request.NettyRequestSender.newNettyRequestAndResponseFuture(NettyRequestSender.java:216)
I guess the method HttpUtil.isEncodingSafeStartLineToken needs a fix and additional tests, but the fix is not obvious for actual implementation:
public static boolean isEncodingSafeStartLineToken(CharSequence token) {
int i = 0;
int lenBytes = token.length();
int modulo = lenBytes % 4;
int lenInts = modulo == 0 ? lenBytes : lenBytes - modulo;
for (; i < lenInts; i += 4) {
long chars = 1L << token.charAt(i) |
1L << token.charAt(i + 1) |
1L << token.charAt(i + 2) |
1L << token.charAt(i + 3);
if ((chars & ILLEGAL_REQUEST_LINE_TOKEN_OCTET_MASK) != 0) {
return false;
}
}
for (; i < lenBytes; i++) {
long ch = 1L << token.charAt(i);
if ((ch & ILLEGAL_REQUEST_LINE_TOKEN_OCTET_MASK) != 0) {
return false;
}
}
return true;
}
Metadata
Metadata
Assignees
Labels
No labels