Compare commits

...

3 Commits

Author SHA1 Message Date
asonix b9942bcb3d Add changelog entry for h1 shutdown 2025-09-04 17:57:53 -05:00
asonix 965bb5c203 Add test that fails without changes & passes with changes 2025-09-04 17:52:17 -05:00
asonix 016e923138 Remove printlns from dispatcher 2025-09-04 17:52:17 -05:00
3 changed files with 68 additions and 6 deletions

View File

@ -3,6 +3,7 @@
## Unreleased
- Properly wake Payload receivers when feeding errors or EOF
- Shutdown connections when HTTP Responses are written without reading full Requests
## 3.11.1

View File

@ -524,9 +524,6 @@ where
let payload_unfinished = this.payload.is_some();
let not_pipelined = this.messages.is_empty();
println!("not pipelined: {not_pipelined}");
println!("payload unfinished: {payload_unfinished}");
// payload stream finished.
// set state to None and handle next message
this.state.set(State::None);
@ -578,9 +575,6 @@ where
let payload_unfinished = this.payload.is_some();
let not_pipelined = this.messages.is_empty();
println!("not pipelined: {not_pipelined}");
println!("payload unfinished: {payload_unfinished}");
// payload stream finished.
// set state to None and handle next message
this.state.set(State::None);

View File

@ -509,6 +509,73 @@ async fn pipelining_ok_then_ok() {
.await;
}
#[actix_rt::test]
async fn early_response_with_payload_closes_connection() {
lazy(|cx| {
let buf = TestBuffer::new(
"\
GET /unfinished HTTP/1.1\r\n\
Content-Length: 2\r\n\
\r\n\
",
);
let cfg = ServiceConfig::new(
KeepAlive::Os,
Duration::from_millis(1),
Duration::from_millis(1),
false,
None,
);
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
buf.clone(),
services,
cfg,
None,
OnConnectData::default(),
);
pin!(h1);
assert!(matches!(&h1.inner, DispatcherState::Normal { .. }));
match h1.as_mut().poll(cx) {
Poll::Pending => panic!("Should have shut down"),
Poll::Ready(res) => assert!(res.is_ok()),
}
// polls: initial => shutdown
assert_eq!(h1.poll_count, 2);
{
let mut res = buf.write_buf_slice_mut();
stabilize_date_header(&mut res);
let res = &res[..];
let exp = b"\
HTTP/1.1 200 OK\r\n\
content-length: 11\r\n\
date: Thu, 01 Jan 1970 12:34:56 UTC\r\n\r\n\
/unfinished\
";
assert_eq!(
res,
exp,
"\nexpected response not in write buffer:\n\
response: {:?}\n\
expected: {:?}",
String::from_utf8_lossy(res),
String::from_utf8_lossy(exp)
);
}
})
.await;
}
#[actix_rt::test]
async fn pipelining_ok_then_bad() {
lazy(|cx| {