Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix wrong Content-Encoding when enabling both compression and compression-static features #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024

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
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
38 checks passed
@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