iter_bytes w/ chunk_size ignores last non-full chunk #3543
Replies: 7 comments 1 reply
-
|
Are you able to minimally demo this?... |
Beta Was this translation helpful? Give feedback.
-
|
I'm trying to get a minimal reproduction of the issues. Right now I have this extra debugging. iter_bytes with no chunk_sizeiter_bytes with chunk_size = 8 * 1024There are 2,728 bytes that the request with chunk_size misses and the range of the subsequent request is off and not satisfiable. The data and the behavior of the URLs are identical even if the URLs are different. |
Beta Was this translation helpful? Give feedback.
-
|
Side question: why would the library raise a RemoteProtocolError peer closed connection without sending a complete message body (incomplete chunked read) when the transfer-encoding: chunked header is present in the response? |
Beta Was this translation helpful? Give feedback.
-
|
Unfortunately, I can't share the server code. What is wrong with httpx streaming requests and ranges? |
Beta Was this translation helpful? Give feedback.
-
|
@tomchristie @karpetrosyan I have a small demo to show that when using a chunk_size, data gets lost. Included below, you will find the server code, the client code, example runs proving the point,t as well as a client implementation using requests, which works fine. ServerClientResultsUse cURL against the server: Notice the last two words erat sagitti Use httpx without a specified chunk size: Notice the total bytes received are 96, and the last two words are erat sagitti Use httpx with a specified chunk size. This is a broken behavior: Only 64 bytes are received and the last two words don't match with previous runs. The server transmitted the last few words, dignissim sem ut erat sagitti, but they are lost. Client using requestsNotice that with various chunk sizes, all the data makes it through: |
Beta Was this translation helpful? Give feedback.
-
|
@tomchristie @karpetrosyan Any thoughts on this? Shall I submit a Bug Report? |
Beta Was this translation helpful? Give feedback.
-
|
Bug report #3553 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When using iter_bytes with chunk_size any data that is not filling up a full chunk gets lost.
I'm porting a Python library from requests to httpx. I'm replacing a requests.get(stream=True... with httpx.stream("GET"....
In the requests version I'm using:
which I replaced with:
The endpoint returns 10920 bytes, and the requests block reads them all. The httpx block only reads 8192 bytes.
I changed the chunk_size to 1024 and the httpx block only reads 10240 bytes.
If the chunks are not full, the leftover data is lost.
Beta Was this translation helpful? Give feedback.
All reactions