mirror of https://github.com/fafhrd91/actix-web
Compare commits
2 Commits
3942eeecc1
...
43c427d1c0
| Author | SHA1 | Date |
|---|---|---|
|
|
43c427d1c0 | |
|
|
7c0f300d88 |
|
|
@ -11,7 +11,7 @@ use futures_core::Stream;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
body::{BodyStream, BoxBody, MessageBody},
|
body::{BodyStream, BoxBody, MessageBody, SizedStream},
|
||||||
dev::Extensions,
|
dev::Extensions,
|
||||||
error::{Error, JsonPayloadError},
|
error::{Error, JsonPayloadError},
|
||||||
http::{
|
http::{
|
||||||
|
|
@ -335,18 +335,19 @@ impl HttpResponseBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(parts) = self.inner() {
|
let content_length = self
|
||||||
if let Some(length) = parts.headers.get(header::CONTENT_LENGTH) {
|
.inner()
|
||||||
if let Ok(length) = length.to_str() {
|
.and_then(|parts| parts.headers.get(header::CONTENT_LENGTH))
|
||||||
if let Ok(length) = length.parse::<u64>() {
|
.and_then(|value| value.to_str().ok())
|
||||||
self.no_chunking(length);
|
.and_then(|value| value.parse::<u64>().ok());
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if let Some(len) = content_length {
|
||||||
|
self.no_chunking(len);
|
||||||
|
self.body(SizedStream::new(len, stream))
|
||||||
|
} else {
|
||||||
self.body(BodyStream::new(stream))
|
self.body(BodyStream::new(stream))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set a JSON body and build the `HttpResponse`.
|
/// Set a JSON body and build the `HttpResponse`.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue