From 7c0d445119363fd3d4a1bb43987f3fda129a5185 Mon Sep 17 00:00:00 2001 From: bearcage Date: Sat, 15 Jun 2024 15:51:02 -0700 Subject: [PATCH] Add regression tests covering this bug --- src/lib.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 7a21227..5b5c0c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1547,6 +1547,34 @@ mod tests { } } + // A single byte which is part of a method is not invalid + req! { + test_request_one_byte_method, + b"G", Ok(Status::Partial), + |_req| {} + } + + // A subset of a method is a partial method, not invalid + req! { + test_request_partial_method, + b"GE", Ok(Status::Partial), + |_req| {} + } + + // A method, without the delimiting space, is a partial request + req! { + test_request_method_no_delimiter, + b"GET", Ok(Status::Partial), + |_req| {} + } + + // Regression test: assert that a partial read with just the method and + // space results in a partial, rather than a token error from uri parsing. + req! { + test_request_method_only, + b"GET ", Ok(Status::Partial), + |_req| {} + } req! { test_request_partial, @@ -1560,6 +1588,18 @@ mod tests { |_req| {} } + req! { + test_request_method_path_no_delimiter, + b"GET /", Ok(Status::Partial), + |_req| {} + } + + req! { + test_request_method_path_only, + b"GET / ", Ok(Status::Partial), + |_req| {} + } + req! { test_request_partial_parses_headers_as_much_as_it_can, b"GET / HTTP/1.1\r\nHost: yolo\r\n",