Skip to content

Commit

Permalink
Test ability to parse a proxy'ed GET request (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA authored Sep 20, 2024
1 parent 940ec36 commit 136a20c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions http/test/test_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,26 @@ let parse_result_notifies_start_of_body () =
[%test_result: string] ~expect:"foobar"
(String.sub buf ~pos:count ~len:(String.length buf - count))

let parse_proxy_get () =
let buf =
"GET http://example.com/foo.html HTTP/1.1\r\n\
Host: example.com\r\n\
Proxy-Authorization: Basic dXNlcjpwYXNz\r\n\
\r\n\
foobar"
in
let expected_req =
make_req
~headers:
(Http.Header.of_list
[
("Host", "example.com");
("Proxy-Authorization", "Basic dXNlcjpwYXNz");
])
`GET "http://example.com/foo.html"
in
assert_req_success ~here:[ [%here] ] ~expected_req ~expected_consumed:104 buf

open Base_quickcheck

let parse_chunk_length () =
Expand Down Expand Up @@ -250,6 +270,7 @@ let () =
test_case "validate http version" `Quick validate_http_version;
test_case "parse result notified offset of start of optional body"
`Quick parse_result_notifies_start_of_body;
test_case "parse a proxy GET request" `Quick parse_proxy_get;
] );
( "chunked encoding",
[
Expand Down

0 comments on commit 136a20c

Please sign in to comment.