tapir icon indicating copy to clipboard operation
tapir copied to clipboard

[Feature] Add out-of-the-box compression support to Tapir

Open liosedhel opened this issue 1 year ago • 0 comments

It would be great if Tapir supported out-of-the-box compressions.

If the client's request indicates the understanding of some compression algorithms through Accept-Encoding header:

GET /encrypted-area HTTP/1.1
Host: www.example.com
Accept-Encoding: gzip, deflate

The server can respond with, for example, gzip response indicated by Content-Encoding:

HTTP/1.1 200 OK
Date: mon, 26 June 2016 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix)  (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip

The Tapir endpoint definition should probably contain information about which compression algorithm is supported and which is preferred (?). Servers like akka-http can support some of the compression mechanisms, see although it has to be manually incorporated to existing routes with encodeResponse directive. The same can be achieved in Netty through ChannelPipeline HttpContentCompressor step.

Thank you for this feature request consideration! ;)

liosedhel avatar May 09 '23 07:05 liosedhel