Add compression support for tonic-web requests
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
### Crates
tonic-web
### Motivation
We currently have endpoints that return a lot of data, however when using tonic-web, even though the service itself is configured to use Gzip compression the actual response is not compressed. Given the following snippet:
```rs
let svc = SvcServer::new(Svc::new(settings))
.send_compressed(CompressionEncoding::Gzip)
.accept_compressed(CompressionEncoding::Gzip);
Server::builder()
.accept_http1(true)
.add_service(health_service)
.add_service(reflection)
.add_service(tonic_web::enable(svc))
.serve(addr)
.await?;
```
A browser request will include `accept-encoding: gzip, deflate` but the response is always `transfer-encoding: chunked`. The size of the response is also unchanged between enabling/disabling gzip.
I'm assuming this is a limitation with how tonic-web works and hoping this is something that can be implemented there.
### Proposal
Unsure whether this is possible, but adding compression logic into tonic-web the same as exists in the base tonic compression file.
### Alternatives
None that I am aware of.
Contributor guide
Assessment
This issue has not been assessed yet.