Per Request compression
We are using Drogon to build a REST Server to deliver database data. In one instance we store data stored in Avro format. When configuring Drogon to use compression this becomes extremely costly, costs 5-10x more CPU per request and compression is likely very little since the Avro format is a compression format.
Most other data is fine with normal compression.
So the conclusion is that it would be great with a possibility to set compression per request. This should be simple using a new method on HttpResponsePtr. setCompressed (was thought to exist by ChatGPT :) ). Even better would if this method could even set the compression level on a per request level.
Describe the solution you'd like A new method on HttpResponsePtr that is used to set the compression level for the response.
Describe alternatives you've considered Obviously it is possible to use Drogon configuration and also the client can control it. These are good things to use, but the client doesn't necessarily know all the details about which compression is most desirable and one setting per server is not flexible enough.
On further check it seems that one way of accomplishing this behaviour is by setting the ContentType to something that is already compressed like CT_APPLICATION_OCTET_STREAM
Implement a middleware function that checks the response content-type or a custom header, and dynamically sets HttpResponsePtr::setCompression(CompressionLevel) before sending the response, allowing per-request control.