correct vary header

This commit is contained in:
neri 2022-11-22 20:46:37 +01:00
parent 44843ab222
commit 2de28ca5db
1 changed files with 4 additions and 4 deletions

View File

@ -165,11 +165,11 @@ fn build_file_response(
.set_content_disposition(content_disposition);
let mut response = file.into_response(req);
add_headers(req, download, &mut response);
append_security_headers(&mut response, req, download);
Ok(response)
}
fn add_headers(req: &HttpRequest, download: bool, response: &mut HttpResponse) {
fn append_security_headers(response: &mut HttpResponse, req: &HttpRequest, download: bool) {
// if the browser is trying to fetch this resource in a secure context pretend the reponse is
// just binary data so it won't be executed
let sec_fetch_mode = req
@ -186,7 +186,7 @@ fn add_headers(req: &HttpRequest, download: bool, response: &mut HttpResponse) {
// the reponse varies based on these request headers
response
.headers_mut()
.append(VARY, HeaderValue::from_static("accept, sec-fetch-mode"));
.append(VARY, HeaderValue::from_static("sec-fetch-mode"));
}
fn get_disposition_params(filename: &str) -> Vec<DispositionParam> {
@ -229,5 +229,5 @@ fn insert_cache_headers(response: &mut HttpResponse, valid_till: OffsetDateTime)
}
response
.headers_mut()
.insert(VARY, HeaderValue::from_name(ACCEPT));
.append(VARY, HeaderValue::from_name(ACCEPT));
}