1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 16:40:21 +02:00

Always enable content encoding if encoding explicitly selected

This commit is contained in:
Nikolay Kim
2018-01-21 08:31:46 -08:00
parent 1cff4619e7
commit 1914a6a0d8
3 changed files with 10 additions and 6 deletions

View File

@@ -164,8 +164,8 @@ impl HttpResponse {
/// Content encoding
#[inline]
pub fn content_encoding(&self) -> &ContentEncoding {
&self.get_ref().encoding
pub fn content_encoding(&self) -> ContentEncoding {
self.get_ref().encoding
}
/// Set content encoding
@@ -812,11 +812,11 @@ mod tests {
#[test]
fn test_content_encoding() {
let resp = HttpResponse::build(StatusCode::OK).finish().unwrap();
assert_eq!(*resp.content_encoding(), ContentEncoding::Auto);
assert_eq!(resp.content_encoding(), ContentEncoding::Auto);
let resp = HttpResponse::build(StatusCode::OK)
.content_encoding(ContentEncoding::Br).finish().unwrap();
assert_eq!(*resp.content_encoding(), ContentEncoding::Br);
assert_eq!(resp.content_encoding(), ContentEncoding::Br);
}
#[test]