0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 15:21:26 -05:00

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

This commit is contained in:
Matt Mastracci 2024-01-26 10:33:55 -05:00 committed by Bartek Iwańczuk
parent 568ba673a8
commit d2643fadb9
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 11 additions and 4 deletions

View file

@ -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) {

View file

@ -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,
_ => (),
}