diff --git a/README.md b/README.md index 533049e6..4d9795c9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Actix web is licensed under the [Apache-2.0 license](http://opensource.org/licen * Streaming and pipelining * Keep-alive and slow requests handling * [WebSockets](https://actix.github.io/actix-web/actix_web/ws/index.html) - * Transparent content compression/decompression + * Transparent content compression/decompression (br, gzip, deflate) * Configurable request routing * Multipart streams * Middlewares diff --git a/src/encoding.rs b/src/encoding.rs index 2d6d95b1..f0fdb6bc 100644 --- a/src/encoding.rs +++ b/src/encoding.rs @@ -42,6 +42,15 @@ impl ContentEncoding { ContentEncoding::Identity | ContentEncoding::Auto => "identity", } } + // default quality + fn quality(&self) -> f64 { + match *self { + ContentEncoding::Br => 1.1, + ContentEncoding::Gzip => 1.0, + ContentEncoding::Deflate => 0.9, + ContentEncoding::Identity | ContentEncoding::Auto => 0.1, + } + } } impl<'a> From<&'a str> for ContentEncoding { @@ -464,7 +473,7 @@ impl PayloadEncoder { ContentEncoding::Gzip => ContentEncoder::Gzip( GzEncoder::new(transfer, Compression::Default)), ContentEncoding::Br => ContentEncoder::Br( - BrotliEncoder::new(transfer, 6)), + BrotliEncoder::new(transfer, 5)), ContentEncoding::Identity => ContentEncoder::Identity(transfer), ContentEncoding::Auto => unreachable!() @@ -786,7 +795,7 @@ impl AcceptEncoding { _ => ContentEncoding::from(parts[0]), }; let quality = match parts.len() { - 1 => 1.0, + 1 => encoding.quality(), _ => match f64::from_str(parts[1]) { Ok(q) => q, Err(_) => 0.0,