Skip to content

Commit

Permalink
Start http1 header read timeout even when 0 bytes are read
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Sep 5, 2023
1 parent d342c2c commit 436aee5
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 436aee5

Please sign in to comment.