Skip to content

Commit

Permalink
Test new functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Jan 14, 2025
1 parent 9604f25 commit 1ed8ea0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,50 @@ async fn header_read_timeout_slow_writes_multiple_requests() {
assert!(conn.without_shutdown().await.unwrap_err().is_timeout());
}

#[tokio::test]
async fn header_read_timeout_as_idle_timeout() {
let (listener, addr) = setup_tcp_listener();

thread::spawn(move || {
let mut tcp = connect(&addr);

tcp.write_all(
b"\
GET / HTTP/1.1\r\n\
\r\n\
",
)
.expect("request 1");

thread::sleep(Duration::from_secs(6));

tcp.write_all(
b"\
GET / HTTP/1.1\r\n\
\r\n\
",
)
.expect_err("request 2");
});

let (socket, _) = listener.accept().await.unwrap();
let socket = TokioIo::new(socket);
let conn = http1::Builder::new()
.timer(TokioTimer)
.header_read_timeout(Duration::from_secs(3))
.serve_connection(
socket,
service_fn(|_| {
let res = Response::builder()
.status(200)
.body(Empty::<Bytes>::new())
.unwrap();
future::ready(Ok::<_, hyper::Error>(res))
}),
);
assert!(conn.without_shutdown().await.unwrap_err().is_timeout());
}

#[tokio::test]
async fn upgrades() {
let (listener, addr) = setup_tcp_listener();
Expand Down

0 comments on commit 1ed8ea0

Please sign in to comment.