KEMBAR78
Fix wrong `Content-Encoding` when enabling both compression and compression-static features by joseluisq · Pull Request #471 · static-web-server/static-web-server · GitHub
Skip to content

Conversation

@joseluisq
Copy link
Collaborator

@joseluisq joseluisq commented Aug 12, 2024

Description

This PR fixes a wrong Content-Encoding header value in the response when compression and compression-static features are enabled (either via CLI or a config file) due to SWS compression (dynamic) module performing the post-processing even if a pre-compressed file was found.

Related Issue

It fixes #470

Motivation and Context

How Has This Been Tested?

static-web-server -p 8787 -d docker/public/ --compression --compression-static

Before

curl -sD - -o /dev/null -H "Accept-Encoding: gzip, zstd, br" http://localhost:8787/assets/main.css
# HTTP/1.1 200 OK
# last-modified: Mon, 12 Aug 2024 22:56:47 GMT
# content-type: text/css
# accept-ranges: bytes
# vary: accept-encoding
# content-encoding: gzip, gzip
# cache-control: public, max-age=31536000
# transfer-encoding: chunked
# date: Mon, 12 Aug 2024 23:16:59 GMT

After

curl -sD - -o /dev/null -H "Accept-Encoding: gzip, zstd, br" http://localhost:8787/assets/main.css
# HTTP/1.1 200 OK
# last-modified: Mon, 12 Aug 2024 22:56:47 GMT
# content-type: text/css
# accept-ranges: bytes
# content-encoding: gzip
# vary: accept-encoding
# cache-control: public, max-age=31536000
# transfer-encoding: chunked
# date: Mon, 12 Aug 2024 23:18:14 GMT

Screenshots (if appropriate):

@joseluisq joseluisq added v2 v2 release bugfix This is PR fixes a bug labels Aug 12, 2024
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 12, 2024

Review changes with SemanticDiff.

Analyzed 2 of 3 files.

Filename Status
✔️ tests/compression.rs Analyzed
tests/fixtures/toml/handler_fixtures.toml Unsupported file format
✔️ src/compression.rs Analyzed

@joseluisq joseluisq merged commit a72c7b3 into master Aug 12, 2024
@joseluisq joseluisq deleted the fix-wrong-content-encoding-compressions-enabled branch August 12, 2024 23:32
@joseluisq joseluisq added this to the v2.33.0 milestone Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This is PR fixes a bug v2 v2 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect content-encoding for gzip when file is already available + compression-static

1 participant