Do compress grpc-web responses#408
Conversation
|
@jplatte can you take a look at this one? |
|
Is there a piece of documentation or article that you can link to for justification / proof that this is the right thing to do? I'm not really familiar with GRPC. |
There was a problem hiding this comment.
Change looks good to me, thank you @bouk !
@jplatte To answer your earlier question: native gRPC (application/grpc) has its own compression spec so applying HTTP content-encoding on top would double-compress or break the framing. That's why we skip it in general.
gRPC-web (application/grpc-web, application/grpc-web+proto, etc.) is a different protocol that runs over HTTP/1.1 and thus does not use gRPC's compression framing. It's designed to be treated as a normal HTTP response by intermediaries. Its spec doesn't explicitly specify anything about compression, unfortunately.
But, I found that frameworks like envoy DO respect compression headers for grpc-web. Here you can see both grpc-web and grpc-web+proto explicitly allowlisted in envoy's compression module with values that would match this PR's change:
Good enough for me :)
Related: #215
Motivation
grpc-web responses aren't compressed right now, but they should be.
Solution
Add exception for
application/grpc-weband change exception filter to use starts_with so we match on any encoding format.