mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
update tests for content-encoding
This commit is contained in:
parent
1f5c0f50f9
commit
9c205f9f1d
@ -979,14 +979,32 @@ mod tests {
|
|||||||
.to_request();
|
.to_request();
|
||||||
let res = test::call_success(&mut srv, request);
|
let res = test::call_success(&mut srv, request);
|
||||||
assert_eq!(res.status(), StatusCode::OK);
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
|
assert!(!res.headers().contains_key(header::CONTENT_ENCODING));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_named_file_content_encoding_gzip() {
|
||||||
|
let mut srv = test::init_service(App::new().enable_encoding().service(
|
||||||
|
web::resource("/").to(|| {
|
||||||
|
NamedFile::open("Cargo.toml")
|
||||||
|
.unwrap()
|
||||||
|
.set_content_encoding(header::ContentEncoding::Gzip)
|
||||||
|
}),
|
||||||
|
));
|
||||||
|
|
||||||
|
let request = TestRequest::get()
|
||||||
|
.uri("/")
|
||||||
|
.header(header::ACCEPT_ENCODING, "gzip")
|
||||||
|
.to_request();
|
||||||
|
let res = test::call_success(&mut srv, request);
|
||||||
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.headers()
|
res.headers()
|
||||||
.get(header::CONTENT_ENCODING)
|
.get(header::CONTENT_ENCODING)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
"identity"
|
"gzip"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,10 +296,9 @@ impl Responder for NamedFile {
|
|||||||
header::CONTENT_DISPOSITION,
|
header::CONTENT_DISPOSITION,
|
||||||
self.content_disposition.to_string(),
|
self.content_disposition.to_string(),
|
||||||
);
|
);
|
||||||
// TODO blocking by compressing
|
if let Some(current_encoding) = self.encoding {
|
||||||
// if let Some(current_encoding) = self.encoding {
|
resp.encoding(current_encoding);
|
||||||
// resp.content_encoding(current_encoding);
|
}
|
||||||
// }
|
|
||||||
let reader = ChunkedReadFile {
|
let reader = ChunkedReadFile {
|
||||||
size: self.md.len(),
|
size: self.md.len(),
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user