We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
content-length
This is a followup to #730. Unfortunately, I found a case in which it still does not work correctly.
axum main branch, commit 16ee83a
Debian Linux 12 (“bookworm”) Linux feynman 5.15.0-3-amd64 #1 SMP Debian 5.15.15-1 (2022-01-18) x86_64 GNU/Linux rustc 1.58.1 (db9d1b20b 2022-01-20)
The content-length header in the reply to a simple HEAD request is set to 0 if the corresponding GET request uses transfer-encoding: chunked.
HEAD
GET
transfer-encoding: chunked
Run the example program (which uses tower-http v0.2.1):
use axum::{routing::get, Router}; use tower_http::compression::{predicate::SizeAbove, CompressionLayer}; #[tokio::main] async fn main() { let app = Router::new() .route("/", get(|| async { "Hello, World!" })) .layer(CompressionLayer::new().compress_when(SizeAbove::new(0))); axum::Server::bind(&"0.0.0.0:3000".parse().unwrap()) .serve(app.into_make_service()) .await .unwrap(); }
Send a HTTP/1.1 HEAD request for /. Set the accept-encoding request header to gzip. I used the the following command on the Linux command line:
accept-encoding
gzip
printf 'HEAD / HTTP/1.1\r\naccept-encoding: gzip\r\n\r\n' | nc 127.0.0.1 3000
The output contains the line:
content-length: 0
The output contains no content-length header.
Note the response to the corresponding GET request uses chunked transfer encoding. Its headers look like this:
HTTP/1.1 200 OK content-type: text/plain; charset=utf-8 content-encoding: gzip transfer-encoding: chunked date: Sun, 06 Feb 2022 16:03:44 GMT
The text was updated successfully, but these errors were encountered:
Fix getting content-length for chunked responses
chunked
04c753c
Fixes #747
Fix setting content-length: 0 for HEAD responses with compression m…
c135436
…iddleware (#755) * Fix getting `content-length` for `chunked` responses Fixes #747 * changelog * Fix `cargo deny bans` #753 will fix things properly
Router::nest
Allow
MethodRouter
Successfully merging a pull request may close this issue.
Bug Report
This is a followup to #730. Unfortunately, I found a case in which it still does not work correctly.
Version
axum main branch, commit 16ee83a
Platform
Debian Linux 12 (“bookworm”)
Linux feynman 5.15.0-3-amd64 #1 SMP Debian 5.15.15-1 (2022-01-18) x86_64 GNU/Linux
rustc 1.58.1 (db9d1b20b 2022-01-20)
Description
The
content-length
header in the reply to a simpleHEAD
request is set to 0 if the correspondingGET
request usestransfer-encoding: chunked
.Steps to reproduce
Run the example program (which uses tower-http v0.2.1):
Send a HTTP/1.1
HEAD
request for /. Set theaccept-encoding
request header togzip
. I used the the following command on the Linux command line:Observed behavior
The output contains the line:
Expected behavior
The output contains no
content-length
header.Note the response to the corresponding
GET
request uses chunked transfer encoding. Its headers look like this:The text was updated successfully, but these errors were encountered: