Skip to content

Commit

Permalink
update tests for content-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Apr 4, 2019
1 parent 1f5c0f5 commit 9c205f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
20 changes: 19 additions & 1 deletion actix-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,14 +979,32 @@ mod tests {
.to_request();
let res = test::call_success(&mut srv, request);
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!(
res.headers()
.get(header::CONTENT_ENCODING)
.unwrap()
.to_str()
.unwrap(),
"identity"
"gzip"
);
}

Expand Down
7 changes: 3 additions & 4 deletions actix-files/src/named.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,9 @@ impl Responder for NamedFile {
header::CONTENT_DISPOSITION,
self.content_disposition.to_string(),
);
// TODO blocking by compressing
// if let Some(current_encoding) = self.encoding {
// resp.content_encoding(current_encoding);
// }
if let Some(current_encoding) = self.encoding {
resp.encoding(current_encoding);
}
let reader = ChunkedReadFile {
size: self.md.len(),
offset: 0,
Expand Down

0 comments on commit 9c205f9

Please sign in to comment.