HTTP: respect gzip in serialization #4957
I understood what you are worried about. Indeed, there can be a case where the http server already has a compressed body and set
We must care it.
I realized that the essence of the problem is that there would be a contradiction between
So it'd be better
Here is an image for https://github.com/crystal-lang/crystal/blob/master/src/http/common.cr#L45-L48
encoding = headers["Content-Encoding"]? case encoding when "gzip" body = Gzip::Reader.new(body, sync_close: true) + headers.delete("Content-Encoding")
I like the idea of the headers being consistent with the way the HTTP body appears to the reader, instead of being the original HTTP headers. Although keeping the original HTTP headers around would probably be a good idea. It has the possibility of being confusing though with 2 sets of HTTP headers. It should be well-documented.