Conversation
hyper-util's auto connection reads until it can pick HTTP/1.1 or HTTP/2 and has no timer while it does, and hyper arms its header-read timeout only after that. A peer that connected and sent nothing, or only part of the HTTP/2 preface, therefore held its task and socket until it hung up, even with the default 30 second timeout. Wrap the accepted stream so its reads fail with `TimedOut` if the header-read timeout passes before the bytes read end detection, using the same test as hyper-util. After detection the wrapper passes reads through. An HTTP/2 connection that has sent its preface is still bounded only by the idle and age retirement settings. A timeout too long to add to the clock now disables the bound instead of panicking the connection. Signed-off-by: Iain McGinniss <309153+iainmcgin@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A peer that connects and sends nothing, or only part of the HTTP/2 preface, is held open until it hangs up, even with the default 30 s header-read timeout: hyper-util's auto connection has no timer while it picks a protocol, and hyper starts
header_read_timeoutonly after that. 0.8.1 and 0.9.0 have the same code path.The accepted stream is now wrapped in a private reader that applies hyper-util 0.1.20's
ReadVersionend test to the bytes read and fails the read withio::ErrorKind::TimedOutif the header-read timeout passes first. The connection then ends withCloseReason::Error. After detection the wrapper passes reads through, and hyper's own timer starts, so the first HTTP/1.1 head can take up to twice the timeout.An HTTP/2 connection that has sent the preface is still not bound by this timeout, because idle HTTP/2 clients are normal. A client or proxy that pre-opens connections and sends nothing now has them closed after 30 s.
A header-read timeout too long to add to the clock (
Duration::MAX) now disables the bound instead of panicking every HTTP/1.1 connection. Upgraded IO can no longer be recovered with hyper-util'supgrade::downcast, because the stream type is now private; 0.9.0'saxum::serve_tlsallowed that.