Skip to content

Commit

Permalink
Fixed HTTP client's empty body upload.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Mar 6, 2017
1 parent 6aaa1e2 commit 10c0af9
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -145,9 +145,19 @@ static HttpRequestBase createRequest(HttpReq config) {
req.addHeader("Cookie", joinCookiesAsHeader(cookies));
}

if (config.verb() == HttpVerb.POST || config.verb() == HttpVerb.PUT || config.verb() == HttpVerb.PATCH) {
HttpEntityEnclosingRequestBase entityEnclosingReq = (HttpEntityEnclosingRequestBase) req;
entityEnclosingReq.setEntity(config.body() != null ? byteBody(config) : paramsBody(config.data(), config.files()));
switch (config.verb()) {
case POST:
case PUT:
case PATCH:
HttpEntityEnclosingRequestBase entityEnclosingReq = (HttpEntityEnclosingRequestBase) req;

if (config.body() != null) {
entityEnclosingReq.setEntity(byteBody(config));

} else if (U.notEmpty(config.data()) || U.notEmpty(config.files())) {
entityEnclosingReq.setEntity(paramsBody(config.data(), config.files()));
}
break;
}

req.setConfig(reqConfig(config));
Expand Down

0 comments on commit 10c0af9

Please sign in to comment.