jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chaithanya Ganta <notificati...@github.com>
Subject Re: [jclouds/jclouds] Remove Expect header for requests with empty body (#1120)
Date Tue, 18 Jul 2017 14:18:34 GMT
ChaithanyaGK commented on this pull request.



> @@ -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();
+      }

@nacx Refactored the code to a separate method and added a unit test case to check the functionality.


-- 
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_r127988381
Mime
View raw message