Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
terricain committed Aug 10, 2022
1 parent fde7814 commit fdfea39
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion aiobotocore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
from . import waiter
from .args import AioClientArgsCreator
from .discovery import AioEndpointDiscoveryHandler, AioEndpointDiscoveryManager
from .httpchecksum import apply_request_checksum
from .paginate import AioPaginator
from .retries import adaptive, standard
from .utils import AioS3RegionRedirector
from .httpchecksum import apply_request_checksum

history_recorder = get_global_history_recorder()

Expand Down
13 changes: 8 additions & 5 deletions aiobotocore/httpchecksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from botocore.httpchecksum import (
_CHECKSUM_CLS,
AwsChunkedWrapper,
FlexibleChecksumError,
_apply_request_header_checksum,
_handle_streaming_response,
base64,
logger,
determine_content_length,
conditionally_calculate_md5,
_apply_request_header_checksum,
AwsChunkedWrapper
determine_content_length,
logger,
)


Expand Down Expand Up @@ -107,6 +107,7 @@ async def _handle_bytes_response(http_response, response, algorithm):
raise FlexibleChecksumError(error_msg=error_msg)
return body


def apply_request_checksum(request):
checksum_context = request.get("context", {}).get("checksum", {})
algorithm = checksum_context.get("request_algorithm")
Expand Down Expand Up @@ -155,5 +156,7 @@ def _apply_request_trailer_checksum(request):
body = io.BytesIO(body)

request["body"] = AioAwsChunkedWrapper(
body, checksum_cls=checksum_cls, checksum_name=location_name,
body,
checksum_cls=checksum_cls,
checksum_name=location_name,
)
3 changes: 2 additions & 1 deletion aiobotocore/httpsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ async def send(self, request):
# https://github.com/boto/botocore/issues/1255
headers['Accept-Encoding'] = 'identity'

headers.pop('Transfer-Encoding', '') # aiohttp complains if Transfer-Encoding header is set
# aiohttp complains if Transfer-Encoding header is set
headers.pop('Transfer-Encoding', '')

headers_ = MultiDict(
(z[0], _text(z[1], encoding='utf-8')) for z in headers.items()
Expand Down
11 changes: 9 additions & 2 deletions tests/test_basic_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,21 @@ async def test_head_object_keys(s3_client, create_object, bucket_name):
}


@pytest.mark.xfail(reason="SHA256 Checksums on streaming objects are only sent in trailers unsigned over HTTPS")
@pytest.mark.xfail(
reason="SHA256 Checksums on streaming objects are only sent in trailers unsigned over HTTPS"
)
@pytest.mark.moto
@pytest.mark.asyncio
async def test_put_object_sha256(s3_client, bucket_name):
data = b'test1234'
digest = hashlib.sha256(data).digest()

resp = await s3_client.put_object(Bucket=bucket_name, Key='foobarbaz', Body=data, ChecksumAlgorithm='SHA256')
resp = await s3_client.put_object(
Bucket=bucket_name,
Key='foobarbaz',
Body=data,
ChecksumAlgorithm='SHA256',
)
sha256_trailer_checksum = base64.b64decode(resp['ChecksumSHA256'])

assert digest == sha256_trailer_checksum
15 changes: 9 additions & 6 deletions tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
)
from botocore.hooks import EventAliaser, HierarchicalEmitter
from botocore.httpchecksum import (
_handle_bytes_response,
AwsChunkedWrapper,
_apply_request_trailer_checksum,
_handle_bytes_response,
apply_request_checksum,
handle_checksum_body,
AwsChunkedWrapper,
apply_request_checksum
)
from botocore.httpsession import URLLib3Session
from botocore.paginate import PageIterator, ResultKeyIterator
Expand Down Expand Up @@ -563,11 +563,14 @@
# httpchecksum.py
handle_checksum_body: {'4b9aeef18d816563624c66c57126d1ffa6fe1993'},
_handle_bytes_response: {'76f4f9d1da968dc6dbc24fd9f59b4b8ee86799f4'},
AwsChunkedWrapper._make_chunk: {'097361692f0fd6c863a17dd695739629982ef7e4'},
AwsChunkedWrapper._make_chunk: {
'097361692f0fd6c863a17dd695739629982ef7e4'
},
AwsChunkedWrapper.__iter__: {'261e26d1061655555fe3dcb2689d963e43f80fb0'},
apply_request_checksum: {'bcc044f0655f30769994efab72b29e76d73f7e39'},
_apply_request_trailer_checksum: {'9ef5bdf2d28fe03530f8d58eace28b1d5a368ead'},

_apply_request_trailer_checksum: {
'9ef5bdf2d28fe03530f8d58eace28b1d5a368ead'
},
# retryhandler.py
retryhandler.create_retry_handler: {
'fde9dfbc581f3d571f7bf9af1a966f0d28f6d89d'
Expand Down

0 comments on commit fdfea39

Please sign in to comment.