1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-20 12:45:41 +02:00

non-blocking processing for NamedFile

This commit is contained in:
Nikolay Kim
2018-03-07 17:40:13 -08:00
parent af8875f6ab
commit 42d2a29b1d
5 changed files with 108 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ use std::collections::VecDeque;
use cookie::{Cookie, CookieJar};
use bytes::{Bytes, BytesMut, BufMut};
use futures::Stream;
use http::{StatusCode, Version, HeaderMap, HttpTryFrom, Error as HttpError};
use http::header::{self, HeaderName, HeaderValue};
use serde_json;
@@ -480,6 +481,15 @@ impl HttpResponseBuilder {
Ok(HttpResponse(Some(response)))
}
/// Set a streaming body and generate `HttpResponse`.
///
/// `HttpResponseBuilder` can not be used after this call.
pub fn streaming<S>(&mut self, stream: S) -> Result<HttpResponse, HttpError>
where S: Stream<Item=Bytes, Error=Error> + 'static,
{
self.body(Body::Streaming(Box::new(stream)))
}
/// Set a json body and generate `HttpResponse`
///
/// `HttpResponseBuilder` can not be used after this call.