envoyproxy/envoy

gzip filter: support chunked transfer encoding

Open

#6,632 opened on Apr 18, 2019

View on GitHub
 (13 comments) (4 reactions) (0 assignees)C++ (5,373 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (27,997 stars)
PR merge metrics
 (Avg merge 8d) (378 merged PRs in 30d)

Description

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

Contributor guide