Skip to content
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

fix(ext/http): smarter handling of Accept-Encoding #22130

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli/tests/unit/serve_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,13 @@ const compressionTestCases = [
out: { "Content-Type": "text/plain", "Cache-Control": "no-transform" },
expect: null,
},
{
name: "BadHeader",
length: 1024,
in: { "Accept-Encoding": "\x81" },
out: { "Content-Type": "text/plain", "Cache-Control": "no-transform" },
expect: null,
},
];

for (const testCase of compressionTestCases) {
Expand Down
8 changes: 4 additions & 4 deletions ext/http/http_next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ fn is_request_compressible(
return Compression::None;
};

match accept_encoding.to_str().unwrap() {
match accept_encoding.to_str() {
// Firefox and Chrome send this -- no need to parse
"gzip, deflate, br" => return Compression::Brotli,
"gzip" => return Compression::GZip,
"br" => return Compression::Brotli,
Ok("gzip, deflate, br") => return Compression::Brotli,
Ok("gzip") => return Compression::GZip,
Ok("br") => return Compression::Brotli,
_ => (),
}

Expand Down
Loading