Skip to content

Commit

Permalink
test: parse a header with no after colon
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jun 11, 2024
1 parent 6042bbf commit fb52887
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,4 +2586,20 @@ mod tests {
assert_eq!(response.headers[0].name, "Space-Before-Header");
assert_eq!(response.headers[0].value, &b"hello there"[..]);
}

#[test]
fn test_no_space_after_colon() {
let mut headers = [EMPTY_HEADER; 1];
let mut response = Response::new(&mut headers[..]);
let result = crate::ParserConfig::default()
.parse_response(&mut response, b"HTTP/1.1 200 OK\r\nfoo:bar\r\n\r\n");

assert_eq!(result, Ok(Status::Complete(28)));
assert_eq!(response.version.unwrap(), 1);
assert_eq!(response.code.unwrap(), 200);
assert_eq!(response.reason.unwrap(), "OK");
assert_eq!(response.headers.len(), 1);
assert_eq!(response.headers[0].name, "foo");
assert_eq!(response.headers[0].value, &b"bar"[..]);
}
}

0 comments on commit fb52887

Please sign in to comment.