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

Skip to content

Incorrect Content-Encoding for pre-compressed zstd files #451

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

Closed
7 tasks done
nomeaning777 opened this issue May 29, 2024 · 2 comments · Fixed by #452
Closed
7 tasks done

Incorrect Content-Encoding for pre-compressed zstd files #451

nomeaning777 opened this issue May 29, 2024 · 2 comments · Fixed by #452
Assignees
Labels
bug Something isn't working v2 v2 release
Milestone

Comments

@nomeaning777
Copy link

Search for duplicate issues

  • I already searched, and this issue is not a duplicate.

Issue scope

Library (crate)

Describe the bug

When serving pre-compressed files using zstd, the Content-Encoding header is set to "zst" instead of the correct "zstd". This causes browsers and other clients to fail to handle the content properly.

How to reproduce it

  1. Start the static-web-server with compression-static enabled and with zstd compressed files. e.g.
echo "Test Content" > index.html
zstd index.html
docker run -p 8080:80 -v "$(pwd):/public" joseluisq/static-web-server:2-debian@sha256:8208279b906b8382d616162a8ba04eda00e4b978fac368c282dfb4cb1bfec136  --compression-static=true
  1. Access the server with Accept-Encoding set to zstd, and observe that the Content-Encoding is returned as "zst".
$ curl 127.0.0.1:8080 -v -H "Accept-Encoding: zstd" --compressed 
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.81.0
> Accept: */*
> Accept-Encoding: zstd
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< last-modified: Wed, 29 May 2024 02:46:36 GMT
< content-type: text/html
< accept-ranges: bytes
< content-encoding: zst
< vary: accept-encoding
< cache-control: public, max-age=86400
< transfer-encoding: chunked
< date: Wed, 29 May 2024 02:46:45 GMT
<
curl: (61) Unrecognized content encoding type. libcurl understands deflate, gzip, br, zstd content encodings.

Expected behavior

The Content-Encoding header should be "zstd".

Complementary information

No response

Build target

Docker linux/amd64

Environment and specs

  • static-web-server: v2.31.1
  • Rust: v1.78.0
  • OS: Docker on Ubuntu 22.04
  • Arch: x86_64 (64-bit)
  • Docker: 26.1.3-1
  • Client: curl

Additional context

This behavior is caused by the precompressed_variant function in src/compression_static.rs.

@nomeaning777 nomeaning777 added bug Something isn't working v2 v2 release labels May 29, 2024
@joseluisq joseluisq self-assigned this May 29, 2024
@joseluisq
Copy link
Collaborator

Confirmed, The bug fix should come in the next few minutes.

@joseluisq
Copy link
Collaborator

A patch release should come in the next few days.

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2 v2 release
Projects
None yet
2 participants