fix(http1): return 414 when URI contains more than 65534 characters (#2706)

Previous behavior returned a 404 Bad Request. Conforms to HTTP 1.1 RFC.

Closes #2701
This commit is contained in:
Rajin Gill
2021-11-29 12:31:41 -08:00
committed by GitHub
parent 1010614a0d
commit 5f938fffa6
3 changed files with 30 additions and 2 deletions

View File

@@ -71,6 +71,7 @@ pub(super) enum Parse {
#[cfg(feature = "http1")]
VersionH2,
Uri,
UriTooLong,
Header(Header),
TooLarge,
Status,
@@ -152,7 +153,10 @@ impl Error {
/// Returns true if this was an HTTP parse error caused by a message that was too large.
pub fn is_parse_too_large(&self) -> bool {
matches!(self.inner.kind, Kind::Parse(Parse::TooLarge))
matches!(
self.inner.kind,
Kind::Parse(Parse::TooLarge) | Kind::Parse(Parse::UriTooLong)
)
}
/// Returns true if this was an HTTP parse error caused by an invalid response status code or
@@ -398,6 +402,7 @@ impl Error {
#[cfg(feature = "http1")]
Kind::Parse(Parse::VersionH2) => "invalid HTTP version parsed (found HTTP2 preface)",
Kind::Parse(Parse::Uri) => "invalid URI",
Kind::Parse(Parse::UriTooLong) => "URI too long",
Kind::Parse(Parse::Header(Header::Token)) => "invalid HTTP header parsed",
#[cfg(feature = "http1")]
Kind::Parse(Parse::Header(Header::ContentLengthInvalid)) => {