mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(ext/http): smarter handling of Accept-Encoding (#22130)
This commit is contained in:
parent
98c537726e
commit
c66f7b6d8d
2 changed files with 11 additions and 4 deletions
|
@ -2649,6 +2649,13 @@ const compressionTestCases = [
|
||||||
out: { "Content-Type": "text/plain", "Cache-Control": "no-transform" },
|
out: { "Content-Type": "text/plain", "Cache-Control": "no-transform" },
|
||||||
expect: null,
|
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) {
|
for (const testCase of compressionTestCases) {
|
||||||
|
|
|
@ -558,11 +558,11 @@ fn is_request_compressible(
|
||||||
return Compression::None;
|
return Compression::None;
|
||||||
};
|
};
|
||||||
|
|
||||||
match accept_encoding.to_str().unwrap() {
|
match accept_encoding.to_str() {
|
||||||
// Firefox and Chrome send this -- no need to parse
|
// Firefox and Chrome send this -- no need to parse
|
||||||
"gzip, deflate, br" => return Compression::Brotli,
|
Ok("gzip, deflate, br") => return Compression::Brotli,
|
||||||
"gzip" => return Compression::GZip,
|
Ok("gzip") => return Compression::GZip,
|
||||||
"br" => return Compression::Brotli,
|
Ok("br") => return Compression::Brotli,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue