mirror of https://github.com/fafhrd91/actix-web
Add setting of Content-Length to the no_chunking function
This commit is contained in:
parent
b7649af2a2
commit
0b51f4584c
|
@ -472,7 +472,9 @@ impl ResponseBuilder {
|
|||
|
||||
/// Disable chunked transfer encoding for HTTP/1.1 streaming responses.
|
||||
#[inline]
|
||||
pub fn no_chunking(&mut self) -> &mut Self {
|
||||
pub fn no_chunking(&mut self, len: u64) -> &mut Self {
|
||||
self.header(header::CONTENT_LENGTH, len);
|
||||
|
||||
if let Some(parts) = parts(&mut self.head, &self.err) {
|
||||
parts.no_chunking(true);
|
||||
}
|
||||
|
|
|
@ -371,7 +371,7 @@ async fn test_no_chunking() {
|
|||
let srv = test::start_with(test::config().h1(), || {
|
||||
App::new().service(web::resource("/").route(web::to(move || {
|
||||
HttpResponse::Ok()
|
||||
.no_chunking()
|
||||
.no_chunking(STR.len() as u64)
|
||||
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
|
||||
})))
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue