Skip to content

Commit 8264af0

Browse files
committed
Handles params & queryParams only if maps are not empty
Params were set in the request even if the map of params was empty, this could lead to requests with no body even if we set one. This commit fixes this behaviour for Netty provider. The same has been done for queryParams (in RequestBuilderBase) to prevent '?' to be added even if not wanted
1 parent 0963b7d commit 8264af0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/com/ning/http/client/RequestBuilderBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private String toUrl(boolean encode) {
134134
throw new IllegalArgumentException("Illegal URL: " + url, e);
135135
}
136136

137-
if (queryParams != null) {
137+
if (queryParams != null && !queryParams.isEmpty()) {
138138

139139
StringBuilder builder = new StringBuilder();
140140
if (!url.substring(8).contains("/")) { // no other "/" than http[s]:// -> http://localhost:1234

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
712712
int length = lengthWrapper[0];
713713
nettyRequest.setHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(length));
714714
nettyRequest.setContent(ChannelBuffers.wrappedBuffer(bytes, 0, length));
715-
} else if (request.getParams() != null) {
715+
} else if (request.getParams() != null && !request.getParams().isEmpty()) {
716716
StringBuilder sb = new StringBuilder();
717717
for (final Entry<String, List<String>> paramEntry : request.getParams()) {
718718
final String key = paramEntry.getKey();

0 commit comments

Comments
 (0)