-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Multipart reader fails on Transfer-Encoding: chunked #8643
Comments
Sorry, what is the expected output here? From your code, it looks like you are comparing Content-Length headers to the length of the part, which is nothing to do with multipart. If you expect these to match, the problem is with the creation (or actually, they shouldn't have been included at all), as multipart does not use Content-Length for anything. I also don't see how that relates to chunked transfer encoding, so maybe I'm misunderstanding the problem. |
Sometimes the multipart reader skips a multipart-boundary. This assert should never be triggered: assert b'f9nvedV9b8roNRgHQEYH75IQSkw6UCOJsJSIzCXWhVAXCwPSMrs73NjPQTH5rKARGsWAFa' in body |
The assert doesn't trigger when I run it? I just get the prints underneath. |
Sorry, the assert should trigger: the boundary must separate chunks. I have been tracking this error for about a year - until I managed to build a test case. |
Right, I'm with you. Let me see if I can figure out anything further. It's a bit awkward with such large data to isolate the problem.. |
It only happens rarely, maybe once a week. |
Think it's because the boundary is split across chunks:
|
OK, I think it's only when split across 3+ chunks. Problem is that little chunk in the middle. The chunk size is asserted to be larger than the boundary to protect against this, but I'm guessing there's an edge case where reading from the content stream gives a smaller size than the requested chunk size... |
Yeah, it doesn't account for StreamReader.read() returning data smaller than n, which it may do if it already has data in the buffer. |
Describe the bug
The multipart reader will not parse if
Transfer-Encoding
ischunked
.The reader merges two different parts into one larger multipart.
This request-dump is also required (125 MB; github limits to 25 MB)
http://doppelbauer.name/request-data.txt
To Reproduce
The test case is a bit clumsy, but reproduces the problem.
Expected behavior
Correctly parse multipart
Logs/tracebacks
Python Version
python 3.12
aiohttp Version
Version: 3.10.1
multidict Version
yarl Version
OS
Linux
Related component
Server
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: