S3: head_object() now returns the AcceptRanges header (#6157)

This commit is contained in:
Bert Blommers 2023-04-01 21:20:29 +01:00 committed by GitHub
parent cc9c98fb27
commit d343981916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -1636,6 +1636,7 @@ class S3Response(BaseResponse):
if key:
response_headers.update(key.metadata)
response_headers.update(key.response_dict)
response_headers.update({"AcceptRanges": "bytes"})
if if_unmodified_since:
if_unmodified_since = str_to_rfc_1123_datetime(if_unmodified_since)

View File

@ -56,6 +56,7 @@ def test_s3_server_bucket_create(key_name):
res.status_code.should.equal(200)
assert "ETag" in dict(res.headers)
# ListBuckets
res = test_client.get(
"/", "http://foobaz.localhost:5000/", query_string={"prefix": key_name}
)
@ -66,10 +67,17 @@ def test_s3_server_bucket_create(key_name):
content.should.be.a(dict)
content["Key"].should.equal(key_name)
# GetBucket
res = test_client.head("http://foobaz.localhost:5000")
assert res.status_code == 200
assert res.headers.get("x-amz-bucket-region") == "us-east-1"
# HeadObject
res = test_client.head(f"/{key_name}", "http://foobaz.localhost:5000/")
res.status_code.should.equal(200)
assert res.headers.get("AcceptRanges") == "bytes"
# GetObject
res = test_client.get(f"/{key_name}", "http://foobaz.localhost:5000/")
res.status_code.should.equal(200)
res.data.should.equal(b"test value")