jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds/jclouds] Remove Expect header for PUT and POST reqs with content-length=0 (#1120)
Date Mon, 17 Jul 2017 12:52:58 GMT
nacx requested changes on this pull request.

Thanks @ChaithanyaGK!
@andrewgaul Mind having a look?

> @@ -357,6 +357,22 @@ public GeneratedHttpRequest apply(Invocation invocation) {
       if (request.getPayload() != null) {
          contentMetadataCodec.fromHeaders(request.getPayload().getContentMetadata(), headers);
       }
+
+      boolean isEmptyBody = false;
+      if ("POST".equals(requestMethod) || "PUT".equals(requestMethod)) {

Should we consider "PATCH" operations too?

> @@ -357,6 +357,22 @@ public GeneratedHttpRequest apply(Invocation invocation) {
       if (request.getPayload() != null) {
          contentMetadataCodec.fromHeaders(request.getPayload().getContentMetadata(), headers);
       }
+
+      boolean isEmptyBody = false;
+      if ("POST".equals(requestMethod) || "PUT".equals(requestMethod)) {
+         if (request.getPayload() != null) {
+            Long length = request.getPayload().getContentMetadata().getContentLength();
+            if (length != null && length == 0) {
+               isEmptyBody = true;
+            }
+         } else {
+            isEmptyBody = true;
+         }
+      }
+      if (isEmptyBody) {
+         request = request.toBuilder().removeHeader("Expect").build();
+      }

Let's refactor this to a method that gets a request and returns the modified one so it can
be properly unit-tested.

-- 
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#pullrequestreview-50308589
Mime
View raw message