mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-24 22:37:35 +02:00
cleanup
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
## Content encoding
|
||||
|
||||
Actix automatically *compress*/*decompress* payload.
|
||||
Following encodings are supported:
|
||||
Following codecs are supported:
|
||||
|
||||
* Brotli
|
||||
* Gzip
|
||||
@ -13,17 +13,23 @@ Following encodings are supported:
|
||||
If request headers contains `Content-Encoding` header, request payload get decompressed
|
||||
according to header value. Multiple codecs are not supported, i.e: `Content-Encoding: br, gzip`.
|
||||
|
||||
Response payload get compressed based on `content_encoding` settings.
|
||||
If `ContentEncoding::Auto` is selected then compression depends on request's
|
||||
`Accept-Encoding` header. `ContentEncoding::Identity` could be used to disable compression.
|
||||
If other content encoding is selected the compression is enforced.
|
||||
Response payload get compressed based on *content_encoding* parameter.
|
||||
By default `ContentEncoding::Auto` is used. If `ContentEncoding::Auto` is selected
|
||||
then compression depends on request's `Accept-Encoding` header.
|
||||
`ContentEncoding::Identity` could be used to disable compression.
|
||||
If other content encoding is selected the compression is enforced for this codec. For example,
|
||||
to enable `brotli` response's body compression use `ContentEncoding::Br`:
|
||||
|
||||
```rust
|
||||
extern crate actix_web;
|
||||
use actix_web::*;
|
||||
|
||||
```rust,ignore
|
||||
fn index(req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.content_encoding(ContentEncoding::Br)
|
||||
.body(Body)
|
||||
.body("data").unwrap()
|
||||
}
|
||||
# fn main() {}
|
||||
```
|
||||
|
||||
## JSON Response
|
||||
|
Reference in New Issue
Block a user