Skip to content

Commit

Permalink
fix(http1): start header read timeout immediately (#3305)
Browse files Browse the repository at this point in the history
Co-authored-by: Sean McArthur <sean@seanmonstar.com>
  • Loading branch information
jeromegn and seanmonstar committed Jun 3, 2024
1 parent 093665e commit b5c2592
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,12 @@ pub(super) fn parse_headers<T>(
where
T: Http1Transaction,
{
// If the buffer is empty, don't bother entering the span, it's just noise.
if bytes.is_empty() {
return Ok(None);
}

let span = trace_span!("parse_headers");
let _s = span.enter();

#[cfg(all(feature = "server", feature = "runtime"))]
if !*ctx.h1_header_read_timeout_running {
if let Some(h1_header_read_timeout) = ctx.h1_header_read_timeout {
let span = trace_span!("parse_headers");
let _s = span.enter();

let deadline = Instant::now() + h1_header_read_timeout;
*ctx.h1_header_read_timeout_running = true;
match ctx.h1_header_read_timeout_fut {
Expand All @@ -94,6 +89,14 @@ where
}
}

// If the buffer is empty, don't bother entering the span, it's just noise.
if bytes.is_empty() {
return Ok(None);
}

let span = trace_span!("parse_headers");
let _s = span.enter();

T::parse(bytes, ctx)
}

Expand Down

0 comments on commit b5c2592

Please sign in to comment.