mirror of https://github.com/fafhrd91/actix-web
Remove content_length since it'll be overwritten by the response body. FIXES #1439
This commit is contained in:
parent
b521e9b221
commit
b7649af2a2
|
@ -497,12 +497,6 @@ impl ResponseBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set content length
|
|
||||||
#[inline]
|
|
||||||
pub fn content_length(&mut self, len: u64) -> &mut Self {
|
|
||||||
self.header(header::CONTENT_LENGTH, len)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set a cookie
|
/// Set a cookie
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
|
|
@ -275,7 +275,7 @@ async fn test_h2_head_binary() {
|
||||||
let mut srv = test_server(move || {
|
let mut srv = test_server(move || {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(|_| {
|
.h2(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
|
|
|
@ -281,7 +281,7 @@ async fn test_h2_head_binary() {
|
||||||
let mut srv = test_server(move || {
|
let mut srv = test_server(move || {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(|_| {
|
.h2(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.rustls(ssl_acceptor())
|
.rustls(ssl_acceptor())
|
||||||
})
|
})
|
||||||
|
|
|
@ -490,7 +490,7 @@ async fn test_h1_head_binary() {
|
||||||
let mut srv = test_server(|| {
|
let mut srv = test_server(|| {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h1(|_| {
|
.h1(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.tcp()
|
.tcp()
|
||||||
})
|
})
|
||||||
|
|
|
@ -349,7 +349,7 @@ async fn test_body_br_streaming() {
|
||||||
async fn test_head_binary() {
|
async fn test_head_binary() {
|
||||||
let srv = test::start_with(test::config().h1(), || {
|
let srv = test::start_with(test::config().h1(), || {
|
||||||
App::new().service(web::resource("/").route(
|
App::new().service(web::resource("/").route(
|
||||||
web::head().to(move || HttpResponse::Ok().content_length(100).body(STR)),
|
web::head().to(move || HttpResponse::Ok().body(STR)),
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -372,7 +372,6 @@ async fn test_no_chunking() {
|
||||||
App::new().service(web::resource("/").route(web::to(move || {
|
App::new().service(web::resource("/").route(web::to(move || {
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.no_chunking()
|
.no_chunking()
|
||||||
.content_length(STR.len() as u64)
|
|
||||||
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
|
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
|
||||||
})))
|
})))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue