lpar / gzipped

Replacement for golang http.FileServer which supports precompressed static assets.
BSD 3-Clause "New" or "Revised" License
94 stars 15 forks source link

Please support Transfer-Encoding: gzip, too #13

Open stapelberg opened 4 years ago

stapelberg commented 4 years ago

curl has an option:

--tr-encoding
(HTTP) Request a compressed Transfer-Encoding response using one of the algorithms curl supports, and uncompress the data while receiving it.

Using it results in a TE header and the Connection header set to TE.

% curl -v  --tr-encoding http://localhost/pkg/nano-amd64-4.9.2-5.squashfs | hexdump -C | head
> GET /pkg/nano-amd64-4.9.2-5.squashfs HTTP/1.1
> Host: localhost
> User-Agent: curl/7.69.0
> Accept: */*
> Connection: TE
> TE: gzip
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 2375680
< Content-Type: application/octet-stream
< Last-Modified: Mon, 11 May 2020 08:33:31 GMT
< Date: Fri, 15 May 2020 17:16:25 GMT

[uncompressed file contents]

If I understand the answers at https://stackoverflow.com/questions/11641923/transfer-encoding-gzip-vs-content-encoding-gzip?rq=1 correctly, transfer-encoding is the better header to use for opting into compression (because it does not mess with proxies), but also the more rarely used one.

It would be great if this package would not only support Accept-Encoding, but also Transfer-Encoding, so that curl users can opt into compression.

lpar commented 4 years ago

Note that you can set accept-encoding using curl.