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:
@@ -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.
|
||||
|
Reference in New Issue
Block a user