-
Notifications
You must be signed in to change notification settings - Fork 54
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
Question: can frame.into_data() be incomplete? #101
Comments
Are you intending to buffer the whole response body? If so, then yes it might contain more than one frame. You can get the whole response using body.collect().await?.to_bytes() |
It's not that it's incomplete, but this a common misconception: writes from a peer do not equal the exact same reads locally. There are multiple things that can make a write get cut up into smaller pieces: TCP segment size, HTTP/2 DATA frame size, TLS record size, proxies/intermediaries. You essentially want something like Enough people have asked about this that it makes me think we could probably come up with a helper in |
No, the body is endless.
Okay Looking at the spec a little bit more: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Encoded_data it seems that my |
@seanmonstar reading more I think I found where I got confused. In HTTP2, which doesn't have So the name |
I use
http-body
to parse the body of an endlessTransfer-Encoding: Chunked
stream.But as I've discovered, under certain conditions
data
is incomplete. When complete it ends in\n
.To fix it I have a buffer that I only parse out the part of
[0..(index of first b'\n']
and remove it from the buffer.This leaves me with the following questions:
Frame
? Having a partial piece in there?\n
a left-over from the Chunked separator\r\n
?The text was updated successfully, but these errors were encountered: