Skip to content

Commit

Permalink
condition serving pre-zipped content based on value of Accept-Encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
hcldan committed Jan 31, 2024
1 parent 83a2fc1 commit 1aae6cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/lib/src/fs/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ impl Handler for FileServer {
index.respond_to(req).or_forward((data, Status::NotFound))
},
Some(mut p) => {
let check_compressed = options.contains(Options::CheckCompressed);
let gzip_accepted = req.headers().get("Accept-Encoding")
.find(|value| value.contains("gzip"))
.is_some();
let check_compressed = gzip_accepted && options.contains(Options::CheckCompressed);
if check_compressed {
if let Some(file) = p.file_name() {
let mut compressed = file.to_os_string();
Expand Down

0 comments on commit 1aae6cd

Please sign in to comment.