jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Gaul <notificati...@github.com>
Subject Re: [jclouds/jclouds] Remove Expect header for requests with empty body (#1120)
Date Wed, 19 Jul 2017 20:31:42 GMT
andrewgaul commented on this pull request.



> @@ -779,6 +782,22 @@ private static void addHeader(Multimap<String, String> headers,
Headers header,
       return parts.build();
    }
 
+   private static GeneratedHttpRequest stripExpectHeaderIfContentZero(GeneratedHttpRequest
request) {
+      boolean isBodyEmpty = false;
+      if (request.getPayload() != null) {
+         Long length = request.getPayload().getContentMetadata().getContentLength();
+         if (length != null && length == 0) {
+            isBodyEmpty = true;
+         }
+      } else {
+         isBodyEmpty = true;
+      }

I tested removing Content-Length from `BaseBlobIntegrationTest.testPutInputStream` and found:

requires C-L:

* Atmos
* AWS-S3, [reference](https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html)
* Azure Blob, [reference](https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob)
* B2, [reference](https://www.backblaze.com/b2/docs/b2_upload_file.html)

requires C-L but should not:

* GCS, [reference](https://cloud.google.com/storage/docs/json_api/v1/objects/insert)

does not require C-L but should:

* Rackspace Cloud Files/OpenStack Swift, [reference](https://developer.openstack.org/api-ref/object-storage/?expanded=create-or-replace-object-detail#create-or-replace-object)

I do not understand jclouds chunked encoding support well enough to comment but otherwise
our portable call sites should set Content-Length.  For what it is worth I prefer the original
code which does not assume a Content-Length and not the suggested change.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1120#discussion_r128358733
Mime
View raw message