File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1632,6 +1632,50 @@ async fn header_read_timeout_slow_writes_multiple_requests() {
16321632 assert ! ( conn. without_shutdown( ) . await . unwrap_err( ) . is_timeout( ) ) ;
16331633}
16341634
1635+ #[ tokio:: test]
1636+ async fn header_read_timeout_as_idle_timeout ( ) {
1637+ let ( listener, addr) = setup_tcp_listener ( ) ;
1638+
1639+ thread:: spawn ( move || {
1640+ let mut tcp = connect ( & addr) ;
1641+
1642+ tcp. write_all (
1643+ b"\
1644+ GET / HTTP/1.1\r \n \
1645+ \r \n \
1646+ ",
1647+ )
1648+ . expect ( "request 1" ) ;
1649+
1650+ thread:: sleep ( Duration :: from_secs ( 6 ) ) ;
1651+
1652+ tcp. write_all (
1653+ b"\
1654+ GET / HTTP/1.1\r \n \
1655+ \r \n \
1656+ ",
1657+ )
1658+ . expect_err ( "request 2" ) ;
1659+ } ) ;
1660+
1661+ let ( socket, _) = listener. accept ( ) . await . unwrap ( ) ;
1662+ let socket = TokioIo :: new ( socket) ;
1663+ let conn = http1:: Builder :: new ( )
1664+ . timer ( TokioTimer )
1665+ . header_read_timeout ( Duration :: from_secs ( 3 ) )
1666+ . serve_connection (
1667+ socket,
1668+ service_fn ( |_| {
1669+ let res = Response :: builder ( )
1670+ . status ( 200 )
1671+ . body ( Empty :: < Bytes > :: new ( ) )
1672+ . unwrap ( ) ;
1673+ future:: ready ( Ok :: < _ , hyper:: Error > ( res) )
1674+ } ) ,
1675+ ) ;
1676+ assert ! ( conn. without_shutdown( ) . await . unwrap_err( ) . is_timeout( ) ) ;
1677+ }
1678+
16351679#[ tokio:: test]
16361680async fn upgrades ( ) {
16371681 let ( listener, addr) = setup_tcp_listener ( ) ;
You can’t perform that action at this time.
0 commit comments