haskell-servant / haskell-servant/servant
Add Content-Length header
- Dominant language
- Haskell
- Stars
- 2k
- Forks
- 427
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 5
Description
When using servant, none of the end-points return a "Content-Length" header. Instead, all of the response bodies are returned streaming.
Since servant endpoints generally always return a full object (JSON object, HTML object, etc...), I believe the size of the response is known, and the "Content-Length" header can be set.
The missing "Content-Length" header causes degraded performance when using [Network.Wai.Middleware.Gzip](https://hackage.haskell.org/package/wai-extra) middleware. This is because that middleware checks the "Content-Length" header in order to skip compression on small response bodies (less than 860 bytes). The source is here: and here is the reasoning:
Servant is typically used for JSON APIs, so many responses in real projects will be small JSON payloads (less than 860 bytes).
Contributor guide
Assessment
This issue has not been assessed yet.