-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
S3: head_object and get_object should accept the same parameters #3945
Comments
Hi @jrandall thanks for reaching out. In the documentation for the HeadObject API it notes:
So the Response* parameters you referenced are intentionally excluded by design. Also these service API models are provided by the S3 team - and for questions involving service API functionality we recommend reaching out through AWS Support. For feedback on the documentation we recommend using the Provide feedback link at the bottom of API docs pages. |
|
Hi @tim-finnigan - thanks for your attention and for looking into this. The documentation you cited is exactly the documentation that tells me that the response parameters should be accepted by the HEAD method.
To be clear, the response options do not in any way alter the response body, they only alter the headers sent back in the response. See the documentation for GetObject:
At an HTTP level, the purpose of making a HEAD request on a resource is to examine the headers of the response that would be sent if a GET request were made, but without transferring the actual payload body. From RFC7231:
To be clear, with the AWS S3 service this is possible. The S3 service itself appears to implement this completely consistently with the documentation and the expected HTTP semantics. The only issue here is that the API documentation and the clients (such as boto3 / botocore) whose implementation is generated from the API model shared by the documentation does not specifically list the response parameters in the Without support for the response options, a presigned URL for the HEAD method cannot be constructed that would give the same headers as a presigned URL for the GET method that sets the Response* options, because the headers in the response would be set differently in the GET response and the HEAD response. This is exactly the issue I am having. I can use a third-party library for interacting with S3 and avoid this issue, but I thought it would be good to bring it to your attention so that you can fix all of the AWS supported SDK libraries. I will raise this issue through the documentation feedback form as well, as you suggest. |
Just a note to say that I did pursue this with the AWS S3 service team and they have now released the fix. Public facing documentation has been fixed, and as of botocore and boto3 1.34.138, all of the response overrides available to the |
Describe the bug
The documentation for HeadObject says that "A HEAD request has the same options as a GET action on an object." This is consistent with the HTTP semantics for HEAD as defined in RFC7231 section 4.3.2. I have verified that the AWS S3 service does in fact accept all of the parameters for
GetObject
as parameters toHeadObject
and that the response is identical to that of aGetObject
request.However, when the documentation goes on to enumerate the set of URI Request Parameters listed for HeadObject, this does not match the set of URI Request Parameters listed for GetObject in that the former
HeadObject
set is missing the sixresponse-*
parameters that are present in the latterGetObject
set.My guess is that this documentation and the botocore service description for s3 are generated from the same source material, and as a result the botocore client does not accept the six
Response*
parameters tohead_object
that are accepted byget_object
. Importantly, this is also a problem when generating a presigned URL (e.g. by callinggenerate_presigned_url
withClientMethod='head_object'
).When building an HTTP service that generates pre-signed S3 URLs to which it redirects its own GET requests (including setting custom response headers), this limitation means it is not possible to implement a semantically appropriate response to a HEAD request. Ideally, we could call
generate_presigned_url
with exactly the same set ofParams
and just change theClientMethod
fromget_object
when redirecting aGET
request andhead_object
when redirecting aHEAD
request.Expected Behavior
Calls to
head_object
should accept the same parameters as calls toget_object
and calls togenerate_presigned_url
withClientMethod='head_object'
should accept the same parameters as withClientMethod='get_object'
Current Behavior
Reproduction Steps
Possible Solution
I have confirmed that the simple fix of modifying the S3 service description in botocore such that the
members
field forHeadObjectRequest
is identical to that ofGetObjectRequest
(by simply copying the six entries from GetObjectRequest to the appropriate place in HeadObjectRequest ) solves this issue completely.Patch:
Additional Information/Context
No response
SDK version used
boto3 1.29.5, botocore 1.32.5
Environment details (OS name and version, etc.)
Darwin 23.1.0 arm64
The text was updated successfully, but these errors were encountered: