Fix range headers: use response_headers parameters instead of creating a new dict (#4502)
This commit is contained in:
parent
ff1714af15
commit
ecdd395bec
@ -984,8 +984,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
||||
template.render(deleted=deleted_objects, delete_errors=error_names),
|
||||
)
|
||||
|
||||
def _handle_range_header(self, request, headers, response_content):
|
||||
response_headers = {}
|
||||
def _handle_range_header(self, request, response_headers, response_content):
|
||||
length = len(response_content)
|
||||
last = length - 1
|
||||
_, rspec = request.headers.get("range").split("=")
|
||||
|
@ -6486,3 +6486,24 @@ def test_head_object_should_return_default_content_type():
|
||||
s3.Object("testbucket", "testobject").content_type.should.equal(
|
||||
"binary/octet-stream"
|
||||
)
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_request_partial_content_should_contain_all_metadata():
|
||||
# github.com/spulec/moto/issues/4203
|
||||
bucket = "bucket"
|
||||
object_key = "key"
|
||||
body = "some text"
|
||||
query_range = "0-3"
|
||||
|
||||
s3 = boto3.resource("s3", region_name=DEFAULT_REGION_NAME)
|
||||
s3.create_bucket(Bucket=bucket)
|
||||
obj = boto3.resource("s3").Object(bucket, object_key)
|
||||
obj.put(Body=body)
|
||||
|
||||
response = obj.get(Range="bytes={}".format(query_range))
|
||||
|
||||
assert response["ETag"] == obj.e_tag
|
||||
assert response["LastModified"] == obj.last_modified
|
||||
assert response["ContentLength"] == 4
|
||||
assert response["ContentRange"] == "bytes {}/{}".format(query_range, len(body))
|
||||
|
Loading…
Reference in New Issue
Block a user