From bb6c38a345fa788bd76a05d8f6d2279a156ea52d Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 1 Apr 2013 13:33:31 -0700 Subject: [PATCH] Emit Content-Length: 0 for empty PUTs HttpUrlConnection reverts Content-Length: 0 on PUT without doOutput(true), similar to POST. This commit allows Azure container create to succeed. Closes #1420. --- .../http/internal/JavaUrlHttpCommandExecutorService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index cc2ca8a576..11ee8d3f95 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -231,8 +231,9 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe 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); }