mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 16:02:59 +01:00
separate ResponseLength::Zero is not needed
This commit is contained in:
parent
805e7a4cd0
commit
3984ad45df
@ -158,7 +158,8 @@ impl Codec {
|
||||
buffer.extend_from_slice(b"\r\ntransfer-encoding: chunked\r\n")
|
||||
}
|
||||
ResponseLength::Zero => {
|
||||
buffer.extend_from_slice(b"\r\ncontent-length: 0\r\n")
|
||||
len_is_set = false;
|
||||
buffer.extend_from_slice(b"\r\n")
|
||||
}
|
||||
ResponseLength::Length(len) => {
|
||||
helpers::write_content_length(len, buffer)
|
||||
@ -169,10 +170,6 @@ impl Codec {
|
||||
buffer.extend_from_slice(b"\r\n");
|
||||
}
|
||||
ResponseLength::None => buffer.extend_from_slice(b"\r\n"),
|
||||
ResponseLength::HeaderOrZero => {
|
||||
len_is_set = false;
|
||||
buffer.extend_from_slice(b"\r\n")
|
||||
}
|
||||
}
|
||||
|
||||
// write headers
|
||||
@ -185,7 +182,7 @@ impl Codec {
|
||||
TRANSFER_ENCODING => continue,
|
||||
CONTENT_LENGTH => match self.te.length {
|
||||
ResponseLength::None => (),
|
||||
ResponseLength::HeaderOrZero => {
|
||||
ResponseLength::Zero => {
|
||||
len_is_set = true;
|
||||
}
|
||||
_ => continue,
|
||||
|
@ -17,10 +17,8 @@ use response::Response;
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum ResponseLength {
|
||||
Chunked,
|
||||
/// Content length is 0
|
||||
Zero,
|
||||
/// Check if headers contains length or write 0
|
||||
HeaderOrZero,
|
||||
Zero,
|
||||
Length(usize),
|
||||
Length64(u64),
|
||||
/// Do no set content-length
|
||||
@ -82,7 +80,7 @@ impl ResponseEncoder {
|
||||
| StatusCode::CONTINUE
|
||||
| StatusCode::SWITCHING_PROTOCOLS
|
||||
| StatusCode::PROCESSING => ResponseLength::None,
|
||||
_ => ResponseLength::HeaderOrZero,
|
||||
_ => ResponseLength::Zero,
|
||||
};
|
||||
TransferEncoding::empty()
|
||||
}
|
||||
|
@ -123,6 +123,12 @@ fn test_content_length() {
|
||||
.unwrap();
|
||||
let response = sys.block_on(req.send()).unwrap();
|
||||
assert_eq!(response.headers().get(&header), None);
|
||||
|
||||
let req = client::ClientRequest::head(format!("http://{}/{}", addr, i))
|
||||
.finish()
|
||||
.unwrap();
|
||||
let response = sys.block_on(req.send()).unwrap();
|
||||
assert_eq!(response.headers().get(&header), None);
|
||||
}
|
||||
|
||||
for i in 4..6 {
|
||||
@ -254,7 +260,6 @@ fn test_head_empty() {
|
||||
assert!(response.status().is_success());
|
||||
|
||||
{
|
||||
println!("RESP: {:?}", response);
|
||||
let len = response
|
||||
.headers()
|
||||
.get(http::header::CONTENT_LENGTH)
|
||||
|
Loading…
Reference in New Issue
Block a user