How can I tell the web server that I am sending gzipped data?

I have a client that will send large JSON files to the API server. Since the files are so compressible, I would like to gzip them and send the compressed data.

What I would like to know: what is the best way to signal my server intent?

Basically, I want the opposite side of Accept-encoding , so that the server will process the data as compressed only for transport purposes and automatically decompress the data before interpreting it according to the Content-Type .

This means that I cannot set the Content-Type field to application/gzip , because the server must have application/json to understand what true uncompressed data encoding is.

Content-Transfer-Encoding looks like it will serve my purpose, but it was created with email in mind and only supports 7bit , quoted-printable , base64 , 8bit and binary .

Is there transparent compression / decompression for HTTP transport from client to server? And if not, what are the best practices for what I'm trying to achieve?

+4
source share
1 answer

The reverse of the Accept-encoding header is Content-encoding . This signals the server that the contents of gzipped are:

  Content-encoding: gzip

You are right that you should not use the Content-type header for this, since gzip compression is just a matter of encoding the request, not what it represents.

+2
source

Source: https://habr.com/ru/post/1399570/


All Articles