sttp
sttp copied to clipboard
#1918 gzip and deflate content codecs
Hello! Can you look at my suggestion of concept for request content encoding support?
Thanks for looking into this!
I think I would have two general suggestions:
- the compression should probably be handled in the backends themselves. Right now, if you have a chain of
Backend
s with delegates, the first one would perform the compression of the body and passed the compressed body to its delegate. I think this should rather happen at the end of the chain, right before sending. So any metrics, logging, redirect etc. backends would get the uncompressed body - then, the backends could use our default methods of compression, or use their built-in ones. For sure the default backend doesn't handle compression (based on Java's
HttpClient
), but maybe pekko-http, or async-http-client do? Something to check :)
In a somewhat similar fashion we handle decompressino (see e.g. customEncodingHandler
and standardEncoding
in HttpClientBackend
)
Thanks for looking into this!
I think I would have two general suggestions:
- the compression should probably be handled in the backends themselves. Right now, if you have a chain of
Backend
s with delegates, the first one would perform the compression of the body and passed the compressed body to its delegate. I think this should rather happen at the end of the chain, right before sending. So any metrics, logging, redirect etc. backends would get the uncompressed body- then, the backends could use our default methods of compression, or use their built-in ones. For sure the default backend doesn't handle compression (based on Java's
HttpClient
), but maybe pekko-http, or async-http-client do? Something to check :)In a somewhat similar fashion we handle decompressino (see e.g.
customEncodingHandler
andstandardEncoding
inHttpClientBackend
)
Hello! Thank u for the answer. I will try to implement compression on one of the backends in the near future.
Great :) I suspect the default backend - HttpClientBackend
- would be the best one to tackle first