1

I've configured apache 2.4 to compress content before it is delivered to the client, using mod_deflate and the clients header set to "Accept-Encoding: gzip". So this I got already working, producing a valid gzipped file:

curl --header "Accept-Encoding: gzip" https://my.website/ > content.gz

Is there a way to allow "Accept-Encoding: zip" to compress as zip?

As far as I understand the documentation this seems not possible:

The gzip encoding is the only one supported to ensure complete compatibility with old browser implementations. The deflate encoding is not supported ... (https://httpd.apache.org/docs/2.4/mod/mod_deflate.html)

Question comes from a Windows user who cannot unzip gzip files (I guess using only Windows native tools).

[edit: as gerald-schneider noted a browser will automatically decompress the content - but we are using curl and such command line tools to be able to script the API and thus there is no browser involved. Thanks also all the other answers and comments, I think I should have be more precise , i.e. writing down the curl command to begin with].

dr0i
  • 251

3 Answers3

3

I think you misunderstood what the compression in the HTTP protocol is for. It is not for downloading archives. It is to reduce the data that is transferred when you are just browsing. The files that are compressed by it are HTML, CSS, JavaScripts and images. The decompression is handled by the browser before it displays the pages. And the browsers can handle gzip just fine on Windows.

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97
3

As pointed out in the question's citation of the apache documentation it is not possible to configure apache to serve content compressed as zip with the mod_deflate and client's header set to Accept-Encoding: zip. Only gzip works. If a user uses a browser that browser will decode it on the fly. If the user downloads the content with e.g. curl she has to gunzip the gziped content, be it with OS native tools or installed ones (the latter necessary for e.g. Windows users).

dr0i
  • 251
0

Reading your comment, I am a bit unsure of what you are asking:

  • Do you want your apache server to send normal (think html or plaintext) file with a Zip encoding instead of Gzip? (Impossible according to documentation)
  • Do you want curl to be able to fetch data from your server? (in that case, you don't need to worry about the encoding as it is just a "minor" network optimisation)
  • Do you want to have curl download some zip content? In that case you should instead configure httpd so it serve directly your zip archive with some "static file" settings

Anyway, I am not sure the content-encoding is what you are looking for here...