in src/clients/s3_client.py [0:0]
def _contains_error(self, response) -> Tuple[bool, Tuple[str, str, S3_STATUS_CODES]]:
text = response.content.decode('utf-8')
lines = text.split('\n')
# All 200-299 status codes are succesfull responses . 206 is for partial code .
if response.status_code >= 300 or (len(lines) > 0 and lines[0] == self.XML_HEADER):
xml = ''.join(lines[1:])
LOG.info('Response status code >=300 or text contains xml. ')
error_match = re.search(self.ERROR_RE, xml)
code_match = re.search(self.CODE_RE, xml)
message_match = re.search(self.MESSAGE_RE, xml)
if error_match and code_match and message_match:
error_code = code_match[0]
error_message = message_match[0]
return True, (error_code, error_message, http_status_code_to_s3_status_code(response.status_code))
elif response.status_code >= 300:
return True, (
S3_ERROR_CODES.InternalError.name, "Internal Server Error", http_status_code_to_s3_status_code(response.status_code))
return False, ('', '', http_status_code_to_s3_status_code(response.status_code))