Conversation
`GrpcWebCall` forwarded the size hint of the body it wraps, although it changes the length of what it yields: base64 decoding shrinks a grpc-web-text request, base64 encoding grows a response, a response gains a data frame for its trailers, and a client response loses the trailers frame from its data. HTTP implementations send an exact size hint as the `content-length` of the message (hyper does on HTTP/1.1 and HTTP/2), so a grpc-web-text request with a known length, translated and forwarded over HTTP/2, announced its base64 length and was refused as a protocol error. The hint is now the inner one only where the bytes pass through unchanged (a binary request); the encoder keeps the inner lower bound, an empty call is exactly empty, and the other directions report no bound.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2895
Motivation
GrpcWebCallreturned the size hint of the body it wraps, but it changes thelength of what it yields: base64 decoding shrinks a grpc-web-text request,
encoding grows a response, a response gains a data frame for its trailers, and
a client response loses the trailers frame from its data. hyper sends an exact
hint as
content-length, so a grpc-web-text request with a known length,translated and forwarded over HTTP/2, announced its base64 length and the
server reset the stream (reproduction in the issue).
Solution
The inner hint is now kept only where the bytes pass through unchanged (a
binary request). The encoder keeps the inner lower bound, since it only adds a
trailers frame; an empty call reports exactly zero; the other directions report
no bound.
Tests wrap a body with an exact length in each direction, read it to the end
and check the hint taken beforehand against the bytes yielded. The four changed
directions fail without this change, and the binary request keeps its exact
hint. With the change, the reproduction from the issue gets the SERVING
response and
grpc-status:0.