aboutsummaryrefslogtreecommitdiff
path: root/src/modules/files.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/files.rs')
-rw-r--r--src/modules/files.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/modules/files.rs b/src/modules/files.rs
index 7d6665a..94dab8c 100644
--- a/src/modules/files.rs
+++ b/src/modules/files.rs
@@ -12,7 +12,7 @@ use headers::{
AcceptRanges, CacheControl, ContentLength, ContentRange, ContentType, HeaderMapExt,
LastModified,
};
-use http::header::ACCEPT_LANGUAGE;
+use http::header::{ACCEPT_LANGUAGE, VARY};
use http_body_util::{combinators::BoxBody, BodyExt, StreamBody};
use humansize::FormatSizeOptions;
use hyper::{
@@ -163,16 +163,6 @@ impl Node for Files {
false
};
- // let etag = ETag::from_str(&calc_etag(modified)).map_err(|_| ServiceError::Other)?;
- // let etag_matches = if self.etag {
- // request.headers()
- // .typed_get::<headers::IfNoneMatch>()
- // .map(|if_none_match| if_none_match.precondition_passes(&etag))
- // .unwrap_or_default()
- // } else {
- // false
- // };
-
let range = request.headers().typed_get::<headers::Range>();
let (range_satisfied, range) = bytes_range(range, metadata.len());
@@ -221,12 +211,13 @@ impl Node for Files {
CacheMode::NoStore => CacheControl::new().with_no_store(),
});
- // if self.etag {
- // r.headers_mut().typed_insert(etag);
- // }
if self.last_modified {
r.headers_mut().typed_insert(LastModified::from(modified));
}
+ if self.localize {
+ r.headers_mut()
+ .insert(VARY, HeaderValue::from_static("accept-language"));
+ }
Ok(r)
})