File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -813,7 +813,7 @@ def _extract_headers_from_download(self, response):
813
813
814
814
digests = {}
815
815
for encoded_digest in x_goog_hash .split ("," ):
816
- match = re .match (r"(crc32c|md5)=([\w\d/]+={0,3})" , encoded_digest )
816
+ match = re .match (r"(crc32c|md5)=([\w\d/\+/ ]+={0,3})" , encoded_digest )
817
817
if match :
818
818
method , digest = match .groups ()
819
819
digests [method ] = digest
Original file line number Diff line number Diff line change @@ -1522,6 +1522,24 @@ def test_download_as_string_w_response_headers(self):
1522
1522
self .assertEqual (blob .md5_hash , "CS9tHYTtyFntzj7B9nkkJQ==" )
1523
1523
self .assertEqual (blob .crc32c , "4gcgLQ==" )
1524
1524
1525
+ response = self ._mock_requests_response (
1526
+ http_client .OK ,
1527
+ headers = {
1528
+ "Content-Type" : "application/octet-stream" ,
1529
+ "Content-Language" : "en-US" ,
1530
+ "Cache-Control" : "max-age=1337;public" ,
1531
+ "Content-Encoding" : "gzip" ,
1532
+ "X-Goog-Storage-Class" : "STANDARD" ,
1533
+ "X-Goog-Hash" : "crc32c=4/c+LQ==,md5=CS9tHYTt/+ntzj7B9nkkJQ==" ,
1534
+ },
1535
+ content = b"" ,
1536
+ )
1537
+ blob ._extract_headers_from_download (response )
1538
+ self .assertEqual (blob .content_type , "application/octet-stream" )
1539
+ self .assertEqual (blob .content_language , "en-US" )
1540
+ self .assertEqual (blob .md5_hash , "CS9tHYTt/+ntzj7B9nkkJQ==" )
1541
+ self .assertEqual (blob .crc32c , "4/c+LQ==" )
1542
+
1525
1543
def test_download_as_string_w_hash_response_header_none (self ):
1526
1544
blob_name = "blob-name"
1527
1545
client = mock .Mock (spec = ["_http" ])
You can’t perform that action at this time.
0 commit comments