#2965 - S3 - GetObject - Treat empty Range-argument as a regular GET (#3531)

This commit is contained in:
Bert Blommers 2021-01-13 10:00:18 +00:00 committed by GitHub
parent 77dd35e3b8
commit df8bd43a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -975,7 +975,11 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
else:
status_code, response_headers, response_content = response
if status_code == 200 and "range" in request.headers:
if (
status_code == 200
and "range" in request.headers
and request.headers["range"] != ""
):
try:
return self._handle_range_header(
request, response_headers, response_content

View File

@ -4937,3 +4937,16 @@ def test_request_partial_content_should_contain_actual_content_length():
)
e.response["Error"]["ActualObjectSize"].should.equal("9")
e.response["Error"]["RangeRequested"].should.equal(requested_range)
@mock_s3
def test_request_partial_content_without_specifying_range_should_return_full_object():
bucket = "bucket"
object_key = "key"
s3 = boto3.resource("s3", region_name="us-east-1")
s3.create_bucket(Bucket=bucket)
s3.Object(bucket, object_key).put(Body="some text that goes a long way")
file = s3.Object(bucket, object_key)
response = file.get(Range="")
response["ContentLength"].should.equal(30)