仓库指标
- Star
- (27,997 star)
- PR 合并指标
- (平均合并 8天) (30 天内合并 378 个 PR)
描述
Title: grpc-web: compress response for service methods with non-streaming response
Description:
I have a setup with a frontend making requests to our backend using grpc/grpc-web[^1] via the envoy grpc-web filter.
Currently a response to a simple request-response service method is never compressed, but this is accepted by the grpc-web client and thus should be possible.
I have enabled the envoy.gzip plugin and added application/grpc-web-text+proto and application/grpc-web-text in content_types.
The content being sent by the grpc-web protocol is Base64 encoded proto bytes[^2], meaning the reduction in response size should be significant.
The request headers:
Host: <host-name>
User-Agent: <user-agent>
Accept: application/grpc-web-text
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: <referer>
authorization: <auth-value>
Content-Type: application/grpc-web-text
X-User-Agent: grpc-web-javascript/0.1
X-Grpc-Web: 1
Content-Length: 12
DNT: 1
Connection: keep-alive
TE: Trailers
The response headers:
HTTP/2.0 200 OK
content-type: application/grpc-web-text+proto
grpc-encoding: identity
grpc-accept-encoding: gzip
x-envoy-upstream-service-time: 83
date: <date>
server: <server>
strict-transport-security: max-age=31536000
X-Firefox-Spdy: h2
The only missing requirement for the gzip filter to compress a response[^3] seems to be a missing content length. Unfortunately I can't see the response returned by the various filters (even with --log-level=trace) so I can't be sure this is what is missing.
Relevant Links
- [^1] https://github.com/grpc/grpc-web
- [^2] Unless the grpc services are compiled with
mode=grpcwebbut that completely disables all streaming calls (see README.md) - [^3] https://www.envoyproxy.io/docs/envoy/latest/configuration/http_filters/gzip_filter