You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2019/10/10 17:01:07 UTC

[jclouds] branch 2.1.x updated: Fix null content-length header on HEAD requests

This is an automated email from the ASF dual-hosted git repository.

gaul pushed a commit to branch 2.1.x
in repository https://gitbox.apache.org/repos/asf/jclouds.git


The following commit(s) were added to refs/heads/2.1.x by this push:
     new 6303d96  Fix null content-length header on HEAD requests
6303d96 is described below

commit 6303d9630840e99ea150e6ad192ed4c8b89b8295
Author: Xavier BOURGOUIN <xa...@amadeus.com>
AuthorDate: Thu Oct 10 17:40:29 2019 +0200

    Fix null content-length header on HEAD requests
    
    https://issues.apache.org/jira/projects/JCLOUDS/issues/JCLOUDS-1505
---
 .../jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java b/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java
index 75144f6..57bb2d0 100644
--- a/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java
+++ b/drivers/apachehc/src/main/java/org/jclouds/http/apachehc/ApacheHCHttpCommandExecutorService.java
@@ -88,7 +88,7 @@ public class ApacheHCHttpCommandExecutorService extends BaseHttpCommandExecutorS
       org.apache.http.HttpResponse apacheResponse = executeRequest(nativeRequest);
 
       Payload payload = null;
-      if (apacheResponse.getEntity() != null)
+      if (apacheResponse.getEntity() != null) {
          try {
             payload = Payloads.newInputStreamPayload(apacheResponse.getEntity().getContent());
             if (apacheResponse.getEntity().getContentLength() >= 0)
@@ -99,17 +99,19 @@ public class ApacheHCHttpCommandExecutorService extends BaseHttpCommandExecutorS
             logger.warn(e, "couldn't receive payload for request: %s", nativeRequest.getRequestLine());
             throw e;
          }
+      }
       Multimap<String, String> headers = LinkedHashMultimap.create();
       for (Header header : apacheResponse.getAllHeaders()) {
          headers.put(header.getName(), header.getValue());
       }
       if (payload != null) {
          contentMetadataCodec.fromHeaders(payload.getContentMetadata(), headers);
+         headers = filterOutContentHeaders(headers);
       }
       return HttpResponse.builder().statusCode(apacheResponse.getStatusLine().getStatusCode())
                                    .message(apacheResponse.getStatusLine().getReasonPhrase())
                                    .payload(payload)
-                                   .headers(filterOutContentHeaders(headers)).build();
+                                   .headers(headers).build();
    }
 
    private org.apache.http.HttpResponse executeRequest(HttpUriRequest nativeRequest) throws IOException,