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):
7373 settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
7474
7575
76- def is_retry (response , mode ):
76+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
7777 """Is this method/status code retryable? (Based on allowlists and control
7878 variables such as the number of total retries to allow, whether to
7979 respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
9797 if status in [501 , 505 ]:
9898 return False
9999 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
100106 return False
101107
102108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
7373 settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
7474
7575
76- def is_retry (response , mode ):
76+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
7777 """Is this method/status code retryable? (Based on allowlists and control
7878 variables such as the number of total retries to allow, whether to
7979 respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
9797 if status in [501 , 505 ]:
9898 return False
9999 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
100106 return False
101107
102108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
7373 settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
7474
7575
76- def is_retry (response , mode ):
76+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
7777 """Is this method/status code retryable? (Based on allowlists and control
7878 variables such as the number of total retries to allow, whether to
7979 respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
9797 if status in [501 , 505 ]:
9898 return False
9999 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
100106 return False
101107
102108
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ def retry_hook(settings, **kwargs):
7373 settings ['hook' ](retry_count = settings ['count' ] - 1 , location_mode = settings ['mode' ], ** kwargs )
7474
7575
76- def is_retry (response , mode ):
76+ def is_retry (response , mode ): # pylint: disable=too-many-return-statements
7777 """Is this method/status code retryable? (Based on allowlists and control
7878 variables such as the number of total retries to allow, whether to
7979 respect the Retry-After header, whether this header is present, and
@@ -97,6 +97,12 @@ def is_retry(response, mode):
9797 if status in [501 , 505 ]:
9898 return False
9999 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
100106 return False
101107
102108
You can’t perform that action at this time.
0 commit comments