From 57c53bd2a0eb5599e8f3021df0c3d75ee1a64c80 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 3 Dec 2017 18:58:15 -0800 Subject: [PATCH] add encoding section --- guide/src/qs_7.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/guide/src/qs_7.md b/guide/src/qs_7.md index bfbcb6577..abad8dfe8 100644 --- a/guide/src/qs_7.md +++ b/guide/src/qs_7.md @@ -13,6 +13,19 @@ 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. + +```rust,ignore +fn index(req: HttpRequest) -> HttpResponse { + HttpResponse::Ok() + .content_encoding(ContentEncoding::Br) + .body(Body) +} +``` + ## JSON Response The `Json` type allows you to respond with well-formed JSON data: simply return a value of