sttp icon indicating copy to clipboard operation
sttp copied to clipboard

#1918 gzip and deflate content codecs

Open iyfedorov opened this issue 10 months ago • 3 comments

Hello! Can you look at my suggestion of concept for request content encoding support?

iyfedorov avatar Apr 23 '24 22:04 iyfedorov

Thanks for looking into this!

I think I would have two general suggestions:

  1. the compression should probably be handled in the backends themselves. Right now, if you have a chain of Backends 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
  2. 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)

adamw avatar Apr 24 '24 13:04 adamw

Thanks for looking into this!

I think I would have two general suggestions:

  1. the compression should probably be handled in the backends themselves. Right now, if you have a chain of Backends 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
  2. 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)

Hello! Thank u for the answer. I will try to implement compression on one of the backends in the near future.

iyfedorov avatar Apr 24 '24 21:04 iyfedorov

Great :) I suspect the default backend - HttpClientBackend - would be the best one to tackle first

adamw avatar Apr 25 '24 06:04 adamw