(http_response, response, algorithm)
| 573 | |
| 574 | |
| 575 | def _handle_bytes_response(http_response, response, algorithm): |
| 576 | body = http_response.content |
| 577 | header_name = f"x-amz-checksum-{algorithm}" |
| 578 | checksum_cls = _CHECKSUM_CLS.get(algorithm) |
| 579 | checksum = checksum_cls() |
| 580 | checksum.update(body) |
| 581 | expected = response["headers"][header_name] |
| 582 | if checksum.digest() != base64.b64decode(expected): |
| 583 | error_msg = f"Expected checksum {expected} did not match calculated checksum: {checksum.b64digest()}" |
| 584 | raise FlexibleChecksumError(error_msg=error_msg) |
| 585 | return body |
| 586 | |
| 587 | |
| 588 | _CHECKSUM_CLS = { |
no test coverage detected