Open MatthewScholefield opened 3 years ago
I'm facing the same error, though my case is a 307 instead of 302. The workaround I'm using for now is https://github.com/aio-libs/aiohttp/issues/3654#issuecomment-473873122
This appears to be pretty difficult to do correctly. Currently the file gets closed when the connection is closed. I was hoping we could use expect100 as some kind of solution, but this doesn't resolve the problem and reveals a limitation on the server-side:
The server-side code doesn't have an easy way to send the 302 without first sending a 100-Continue (maybe you can use a custom expect handler, but it would then need to know about all your endpoints, in order to know whether they can be resolved without further data. Maybe we could improve this somehow to only send 100-Continue when a handler tries to read the body?).
π Describe the bug As seen from #1907,
aiohttp
takes ownership of passed files and closes them after writing. However, in the case of a 302 redirect, where I assume thataiohttp
is re-performing the request, it attempts to re-read the data from the closed file.π‘ To Reproduce
Client code:
Server code:
π‘ Expected behavior Successful PUT upload (or to not follow redirects and return a 302 response).
π Logs/tracebacks
π Your version of the Python
π Your version of the aiohttp/yarl/multidict distributions
π Additional context Relates to the client aspect of aiohttp.