Skip to content

Commit

Permalink
Add regression tests covering this bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bearcage authored and seanmonstar committed Jun 17, 2024
1 parent 896f1c1 commit 7c0d445
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down

0 comments on commit 7c0d445

Please sign in to comment.