Skip to content

Commit

Permalink
test(http): line folding (#1064)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Jul 6, 2024
1 parent 95a83ee commit 34e4dc3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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 |}]

0 comments on commit 34e4dc3

Please sign in to comment.