You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use aiohttp to upload a file to an AWS S3 bucket using a pre-signed URL.
The header of the PUT request has a Content-Length parameter. If the length specified in the header differs from the actual length of the data being sent, it will cause a TimeoutError instead of returning a 403 "Forbidden" SignatureDoesNotMatch
In my case, these values can be different because the value in the headers is taken from metadata calculated in a different system. Sending it in the headers is necessary to perform validation.
To Reproduce
with open(file_path, "rb") as f:
async with aiohttp.ClientSession(raise_for_status=False) as async_session:
data = f.read()
headers = {
"Content-MD5": md5_value,
"Content-Length": str(size_value),
"Content-Type": "application/octet-stream",
}
resp = await async_session.request(method='PUT', url=url_s3_presigned, headers=headers, data=data)
Expected behavior
Return response with 403 "Forbidden" instead of raising TimeoutError
This is on making a request. Why do you think it's an issue with aiohttp? As far as I can see from your example, the server is not responding. If that's really the expected format of a request (which seems weird to me), then surely the issue is with the server.
But, I'd expect any HTTP server to respond that way, i.e. if the Content-Length is longer than the data you sent, then it should continue waiting for the rest of the data. How would the server know when the data has finished being sent otherwise?
This is on making a request. Why do you think it's an issue with aiohttp? As far as I can see from your example, the server is not responding. If that's really the expected format of a request (which seems weird to me), then surely the issue is with the server.
But, I'd expect any HTTP server to respond that way, i.e. if the Content-Length is longer than the data you sent, then it should continue waiting for the rest of the data. How would the server know when the data has finished being sent otherwise?
When I am making exactly the same request, using requests or httpx, it just returns 403, which I described earlier.
Describe the bug
I use aiohttp to upload a file to an AWS S3 bucket using a pre-signed URL.
The header of the PUT request has a
Content-Length
parameter. If the length specified in the header differs from the actual length of the data being sent, it will cause aTimeoutError
instead of returning a403 "Forbidden" SignatureDoesNotMatch
In my case, these values can be different because the value in the headers is taken from metadata calculated in a different system. Sending it in the headers is necessary to perform validation.
To Reproduce
Expected behavior
Return response with
403 "Forbidden"
instead of raising TimeoutErrorLogs/tracebacks
Python Version
Python 3.11.6
aiohttp Version
multidict Version
yarl Version
OS
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: