lukeed / sirv

An optimized middleware & CLI application for serving static files~!
MIT License
1.06k stars 56 forks source link

fix: should not set "Content-Encoding" for a direct request of a compressed file #161

Open hi-ogawa opened 1 month ago

hi-ogawa commented 1 month ago

Content-Encoding should be used only when sirv is serving pre-compressed files (e.g. request: test.csv --> response: test.csv.gz), but it should be avoided when users are requesting a compressed file directly (e.g. test.csv.gz).

Citing from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

If the original media is encoded in some way (e.g. a zip file) then this information would not be included in the Content-Encoding header.


The summary of changes in this PR is:

Diff looks a little involved, but I hope this is clear and correct. I would appreciate a review. Thanks!