Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(http): line folding #1064

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions http/test/expect/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(library
(name http_tests)
(libraries http)
(inline_tests)
(preprocess
(pps ppx_expect)))
20 changes: 20 additions & 0 deletions http/test/expect/http_tests.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Parser = Http.Private.Parser

let print_request = function
| Error Parser.Partial -> print_endline "partial header"
| Error (Msg m) -> print_endline m
| Ok (req, n) ->
Format.printf "%a@." Http.Request.pp req;
if n > 0 then Format.printf "leftover: %d@." n

let%expect_test "line folding" =
let buf =
"GET / HTTP/1.1\r\n\
Host: localhost:8080\r\n\
Line-Folded: foo\r\n\
\ bar\r\n\
\r\n\
foboar"
in
print_request (Parser.parse_request buf);
[%expect {| partial header |}]
Loading