Skip to content

Commit

Permalink
http1: add tests for early response body end
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Jan 5, 2024
1 parent f158a77 commit 032f991
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4756,6 +4756,20 @@ mod tests {
rbuf_position: 3,
dest_data: "hel",
},
Test {
name: "known-partial-end",
data: "hel",
end: true,
body_size: BodySize::Known(5),
chunk_left: Some(5),
chunk_size: 0,
chunked: false,
result: Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
chunk_left_after: Some(5),
chunk_size_after: 0,
rbuf_position: 0,
dest_data: "",
},
Test {
name: "known-complete",
data: "hello",
Expand Down Expand Up @@ -4812,6 +4826,20 @@ mod tests {
rbuf_position: 0,
dest_data: "",
},
Test {
name: "chunked-header-partial-end",
data: "5",
end: true,
body_size: BodySize::Unknown,
chunk_left: None,
chunk_size: 0,
chunked: true,
result: Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
chunk_left_after: None,
chunk_size_after: 0,
rbuf_position: 0,
dest_data: "",
},
Test {
name: "chunked-header-parse-error",
data: "z",
Expand Down Expand Up @@ -4868,6 +4896,20 @@ mod tests {
rbuf_position: 6,
dest_data: "hel",
},
Test {
name: "chunked-content-partial-end",
data: "5\r\nhel",
end: true,
body_size: BodySize::Unknown,
chunk_left: None,
chunk_size: 0,
chunked: true,
result: Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
chunk_left_after: Some(2),
chunk_size_after: 5,
rbuf_position: 6,
dest_data: "hel",
},
Test {
name: "chunked-footer-partial-full-none",
data: "5\r\nhello",
Expand All @@ -4882,6 +4924,20 @@ mod tests {
rbuf_position: 8,
dest_data: "hello",
},
Test {
name: "chunked-footer-partial-full-none-end",
data: "5\r\nhello",
end: true,
body_size: BodySize::Unknown,
chunk_left: None,
chunk_size: 0,
chunked: true,
result: Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
chunk_left_after: Some(0),
chunk_size_after: 5,
rbuf_position: 8,
dest_data: "hello",
},
Test {
name: "chunked-footer-partial-full-r",
data: "5\r\nhello\r",
Expand Down Expand Up @@ -4994,6 +5050,20 @@ mod tests {
rbuf_position: 3,
dest_data: "",
},
Test {
name: "trailing-headers-partial-end",
data: "0\r\nhelloXX",
end: true,
body_size: BodySize::Unknown,
chunk_left: None,
chunk_size: 0,
chunked: true,
result: Err(io::Error::from(io::ErrorKind::UnexpectedEof).into()),
chunk_left_after: Some(0),
chunk_size_after: 0,
rbuf_position: 3,
dest_data: "",
},
Test {
name: "trailing-headers-parse-error",
data: "0\r\nhelloXX\n",
Expand Down

0 comments on commit 032f991

Please sign in to comment.