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
Add the "grpc-encoding" header to the response #20
Add the "grpc-encoding" header to the response #20
Conversation
Once the per-message compression encoding has been negotiated (by inspecting the `grpc-accept-encoding` request header), the server should tell the client the chosen encoding (either `identity` or `gzip`) by setting the `grpc-encoding` response header. The meaning of the header is: if any message in the response has its compression flag set, then that message has been compressed using this encoding. Some clients can live with the header being missing. If they encounter a message with its compression flag set, they just assume the encoding is GZip. But other clients, notably the official Java gRPC library, are stricter and require the header to be present. Aside: compression can be done at the stream level rather than the individual message level. In that case, the `content-encoding` header must be set, and the `grpc-encoding` header must *not* be set. None of this is really documented anywhere. I worked it out using Wireshark and reading the [grpc-java source](https://github.com/grpc/grpc-java/blob/8d4240f4800f20de0e5f0b7c213577b3c0324f93/core/src/main/java/io/grpc/internal/AbstractClientStream.java#L313-L356).
putStrLn "running handler" | ||
_ <- handler pickedDecompression pickedCompression req write flush | ||
_ <- handler (pickedDecompression req) (pickedCompression req) req write flush | ||
putStrLn "setting GRPC status" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind if I delete these putStrLn
s while I’m here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do so, I think they should not be there in any case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the PR! I've just release version 0.4.0.1 with this fix 😄 |
Once the per-message compression encoding has been negotiated (by
inspecting the
grpc-accept-encoding
request header), the server shouldtell the client the chosen encoding (either
identity
orgzip
) bysetting the
grpc-encoding
response header.The meaning of the header is: if any message in the response has its
compression flag set, then that message has been compressed using this
encoding.
Some clients can live with the header being missing. If they encounter a
message with its compression flag set, they just assume the encoding is
GZip. But other clients, notably the official Java gRPC library, are
stricter and require the header to be present.
Aside: compression can be done at the stream level rather than the
individual message level. In that case, the
content-encoding
headermust be set, and the
grpc-encoding
header must not be set.None of this is really documented anywhere. I worked it out using
Wireshark and reading the grpc-java source.