From 4fffc16668fc6071fa3c739f8f6c456c79328b24 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 2 Jan 2020 18:36:32 +0600 Subject: [PATCH] fix chunked example --- content/docs/response.md | 11 ----------- examples/responses/Cargo.toml | 2 +- examples/responses/src/chunked.rs | 6 ++---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/content/docs/response.md b/content/docs/response.md index d28d5ed..b63445b 100644 --- a/content/docs/response.md +++ b/content/docs/response.md @@ -71,16 +71,5 @@ The type `T` must implement the `Serialize` trait from *serde*. {{< include-example example="responses" file="json_resp.rs" section="json-resp" >}} -# Chunked transfer encoding - -Chunked encoding on a response can be enabled with `HttpResponseBuilder::chunked()`. -This takes effect only for `Body::Streaming(BodyStream)` or `Body::StreamingContext` bodies. -If the response payload compression is enabled and a streaming body is used, chunked encoding -is enabled automatically. - -> Enabling chunked encoding for *HTTP/2.0* responses is forbidden. - -{{< include-example example="responses" file="chunked.rs" section="chunked" >}} - [responsebuilder]: https://docs.rs/actix-web/2/actix_web/dev/struct.HttpResponseBuilder.html [compressmidddleware]: https://docs.rs/actix-web/2/actix_web/middleware/struct.Compress.html diff --git a/examples/responses/Cargo.toml b/examples/responses/Cargo.toml index ca6de1a..c5366f6 100644 --- a/examples/responses/Cargo.toml +++ b/examples/responses/Cargo.toml @@ -8,4 +8,4 @@ actix-web = "2.0" actix-rt = "1.0" serde = "1.0" futures = "0.3.1" -bytes = "0.4" +bytes = "0.5" diff --git a/examples/responses/src/chunked.rs b/examples/responses/src/chunked.rs index 93eda43..f274879 100644 --- a/examples/responses/src/chunked.rs +++ b/examples/responses/src/chunked.rs @@ -1,12 +1,11 @@ // -use actix_web::{web, HttpRequest, HttpResponse}; +use actix_web::{web, HttpRequest, HttpResponse, Error}; use bytes::Bytes; use futures::future::ok; use futures::stream::once; async fn index(req: HttpRequest) -> HttpResponse { HttpResponse::Ok() - .chunked() .streaming(once(ok::<_, Error>(Bytes::from_static(b"data")))) } // @@ -17,6 +16,5 @@ pub fn main() { HttpServer::new(|| App::new().route("/", web::get().to(index))) .bind("127.0.0.1:8088") .unwrap() - .run() - .unwrap(); + .run(); }