Remove content_length since it'll be overwritten by the response body. FIXES #1439

This commit is contained in:
Omid Rad 2020-05-06 20:29:46 +02:00
parent b521e9b221
commit b7649af2a2
5 changed files with 4 additions and 11 deletions

View File

@ -497,12 +497,6 @@ impl ResponseBuilder {
self
}
/// Set content length
#[inline]
pub fn content_length(&mut self, len: u64) -> &mut Self {
self.header(header::CONTENT_LENGTH, len)
}
/// Set a cookie
///
/// ```rust

View File

@ -275,7 +275,7 @@ async fn test_h2_head_binary() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| {
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
ok::<_, ()>(Response::Ok().body(STR))
})
.openssl(ssl_acceptor())
.map_err(|_| ())

View File

@ -281,7 +281,7 @@ async fn test_h2_head_binary() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| {
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
ok::<_, ()>(Response::Ok().body(STR))
})
.rustls(ssl_acceptor())
})

View File

@ -490,7 +490,7 @@ async fn test_h1_head_binary() {
let mut srv = test_server(|| {
HttpService::build()
.h1(|_| {
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
ok::<_, ()>(Response::Ok().body(STR))
})
.tcp()
})

View File

@ -349,7 +349,7 @@ async fn test_body_br_streaming() {
async fn test_head_binary() {
let srv = test::start_with(test::config().h1(), || {
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 || {
HttpResponse::Ok()
.no_chunking()
.content_length(STR.len() as u64)
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
})))
});