From def144413882c7e4638b9b6cebb513ab3a51a82c Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Fri, 5 Jul 2024 16:08:05 +0100 Subject: [PATCH] feat: set header_read_timeout for exho example to 5 secs --- examples/echo.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/echo.rs b/examples/echo.rs index 60d03b368d..0ec8a9bdb9 100644 --- a/examples/echo.rs +++ b/examples/echo.rs @@ -8,11 +8,13 @@ use hyper::body::Frame; use hyper::server::conn::http1; use hyper::service::service_fn; use hyper::{body::Body, Method, Request, Response, StatusCode}; +use std::time::Duration; use tokio::net::TcpListener; #[path = "../benches/support/mod.rs"] mod support; use support::TokioIo; +use support::TokioTimer; /// This is our service handler. It receives a Request, routes on its /// path, and returns a Future of a Response. @@ -100,6 +102,8 @@ async fn main() -> Result<(), Box> { tokio::task::spawn(async move { if let Err(err) = http1::Builder::new() + .timer(TokioTimer) + .header_read_timeout(Duration::from_secs(5)) .serve_connection(io, service_fn(echo)) .await {