Skip to content

Commit

Permalink
feat: set header_read_timeout for exho example to 5 secs
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jul 5, 2024
1 parent fdc1916 commit def1444
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -100,6 +102,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {

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
{
Expand Down

0 comments on commit def1444

Please sign in to comment.