Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1480 from maginatics/http-put-zero-content-length
Browse files Browse the repository at this point in the history
Emit Content-Length: 0 for empty PUTs
  • Loading branch information
Adrian Cole committed Apr 4, 2013
2 parents d938349 + 843ed57 commit 366a728
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ protected HttpURLConnection convert(HttpRequest request) throws IOException, Int
protected void writeNothing(HttpURLConnection connection) {
if (!HttpRequest.NON_PAYLOAD_METHODS.contains(connection.getRequestMethod())) {
connection.setRequestProperty(CONTENT_LENGTH, "0");
// support zero length posts.
if ("POST".equals(connection.getRequestMethod())) {
// HttpUrlConnection strips Content-Length: 0 without setDoOutput(true)
String method = connection.getRequestMethod();
if ("POST".equals(method) || "PUT".equals(method)) {
connection.setFixedLengthStreamingMode(0);
connection.setDoOutput(true);
}
Expand Down

0 comments on commit 366a728

Please sign in to comment.