Stop autodecoding content so we can mimic requests. Closes #963.
This commit is contained in:
parent
3d886aeadc
commit
49c947ece7
@ -270,6 +270,8 @@ class RequestsMock(object):
|
|||||||
body=body,
|
body=body,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
preload_content=False,
|
preload_content=False,
|
||||||
|
# Need to not decode_content to mimic requests
|
||||||
|
decode_content=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
response = adapter.build_response(request, response)
|
response = adapter.build_response(request, response)
|
||||||
|
@ -6,7 +6,9 @@ import datetime
|
|||||||
from six.moves.urllib.request import urlopen
|
from six.moves.urllib.request import urlopen
|
||||||
from six.moves.urllib.error import HTTPError
|
from six.moves.urllib.error import HTTPError
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
from gzip import GzipFile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
import zlib
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import boto
|
import boto
|
||||||
@ -1405,6 +1407,33 @@ def test_boto3_delete_markers():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_s3
|
||||||
|
def test_get_stream_gzipped():
|
||||||
|
payload = "this is some stuff here"
|
||||||
|
|
||||||
|
s3_client = boto3.client("s3", region_name='us-east-1')
|
||||||
|
s3_client.create_bucket(Bucket='moto-tests')
|
||||||
|
buffer_ = BytesIO()
|
||||||
|
with GzipFile(fileobj=buffer_, mode='w') as f:
|
||||||
|
f.write(payload)
|
||||||
|
payload_gz = buffer_.getvalue()
|
||||||
|
|
||||||
|
s3_client.put_object(
|
||||||
|
Bucket='moto-tests',
|
||||||
|
Key='keyname',
|
||||||
|
Body=payload_gz,
|
||||||
|
ContentEncoding='gzip',
|
||||||
|
)
|
||||||
|
|
||||||
|
obj = s3_client.get_object(
|
||||||
|
Bucket='moto-tests',
|
||||||
|
Key='keyname',
|
||||||
|
)
|
||||||
|
res = zlib.decompress(obj['Body'].read(), 16+zlib.MAX_WBITS)
|
||||||
|
assert res == payload
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_XML = """\
|
TEST_XML = """\
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ns0:WebsiteConfiguration xmlns:ns0="http://s3.amazonaws.com/doc/2006-03-01/">
|
<ns0:WebsiteConfiguration xmlns:ns0="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user