File tree Expand file tree Collapse file tree 4 files changed +28
-4
lines changed
azure-storage-blob/azure/storage/blob/_shared
azure-storage-file-datalake/azure/storage/filedatalake/_shared
azure-storage-file-share/azure/storage/fileshare/_shared
azure-storage-queue/azure/storage/queue/_shared Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
73
73
settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
74
74
75
75
76
- def is_retry (response , mode ):
76
+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
77
77
"""Is this method/status code retryable? (Based on allowlists and control
78
78
variables such as the number of total retries to allow, whether to
79
79
respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
97
97
if status in [501 , 505 ]:
98
98
return False
99
99
return True
100
+ # retry if invalid content md5
101
+ if response .context .get ('validate_content' , False ) and response .http_response .headers .get ('content-md5' ):
102
+ computed_md5 = response .http_request .headers .get ('content-md5' , None ) or \
103
+ encode_base64 (StorageContentValidation .get_content_md5 (response .http_response .body ()))
104
+ if response .http_response .headers ['content-md5' ] != computed_md5 :
105
+ return True
100
106
return False
101
107
102
108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
73
73
settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
74
74
75
75
76
- def is_retry (response , mode ):
76
+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
77
77
"""Is this method/status code retryable? (Based on allowlists and control
78
78
variables such as the number of total retries to allow, whether to
79
79
respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
97
97
if status in [501 , 505 ]:
98
98
return False
99
99
return True
100
+ # retry if invalid content md5
101
+ if response .context .get ('validate_content' , False ) and response .http_response .headers .get ('content-md5' ):
102
+ computed_md5 = response .http_request .headers .get ('content-md5' , None ) or \
103
+ encode_base64 (StorageContentValidation .get_content_md5 (response .http_response .body ()))
104
+ if response .http_response .headers ['content-md5' ] != computed_md5 :
105
+ return True
100
106
return False
101
107
102
108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
73
73
settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
74
74
75
75
76
- def is_retry (response , mode ):
76
+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
77
77
"""Is this method/status code retryable? (Based on allowlists and control
78
78
variables such as the number of total retries to allow, whether to
79
79
respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
97
97
if status in [501 , 505 ]:
98
98
return False
99
99
return True
100
+ # retry if invalid content md5
101
+ if response .context .get ('validate_content' , False ) and response .http_response .headers .get ('content-md5' ):
102
+ computed_md5 = response .http_request .headers .get ('content-md5' , None ) or \
103
+ encode_base64 (StorageContentValidation .get_content_md5 (response .http_response .body ()))
104
+ if response .http_response .headers ['content-md5' ] != computed_md5 :
105
+ return True
100
106
return False
101
107
102
108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
73
73
settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
74
74
75
75
76
- def is_retry (response , mode ):
76
+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
77
77
"""Is this method/status code retryable? (Based on allowlists and control
78
78
variables such as the number of total retries to allow, whether to
79
79
respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
97
97
if status in [501 , 505 ]:
98
98
return False
99
99
return True
100
+ # retry if invalid content md5
101
+ if response .context .get ('validate_content' , False ) and response .http_response .headers .get ('content-md5' ):
102
+ computed_md5 = response .http_request .headers .get ('content-md5' , None ) or \
103
+ encode_base64 (StorageContentValidation .get_content_md5 (response .http_response .body ()))
104
+ if response .http_response .headers ['content-md5' ] != computed_md5 :
105
+ return True
100
106
return False
101
107
102
108
You can’t perform that action at this time.
0 commit comments