You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/08/12 08:28:20 UTC

[GitHub] [libcloud] Kami commented on a change in pull request #1340: Update Azure Blob Storage API version to 2016-05-31

Kami commented on a change in pull request #1340: Update Azure Blob Storage API version to 2016-05-31
URL: https://github.com/apache/libcloud/pull/1340#discussion_r312819617
 
 

 ##########
 File path: libcloud/common/azure.py
 ##########
 @@ -187,14 +187,17 @@ def _get_azure_auth_signature(self,
             else:
                 headers_copy[header] = value
 
+        is_change = method not in ("GET", "HEAD")
+        is_old_api = self.API_VERSION <= "2014-02-14"
+
         # Get the values for the headers in the specific order
         for header in special_header_keys:
             header = header.lower()  # Just for safety
             if header in headers_copy:
                 special_header_values.append(headers_copy[header])
-            elif header == "content-length" and method not in ("GET", "HEAD"):
-                # Must be '0' unless method is GET or HEAD
-                # https://docs.microsoft.com/en-us/rest/api/storageservices/authentication-for-the-azure-storage-services
+            elif header == "content-length" and is_change and is_old_api:
+                # For old API versions, the Content-Length header must be '0'
+                # https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key#content-length-header-in-version-2014-02-14-and-earlier
                 special_header_values.append('0')
 
 Review comment:
   It wouldn't hurt to add a test case for it (we would need to assert inside the mock http class, which means we would also need to make MockHttp class inherit from unittest.TestCase, if not already) :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services