From 34e4dc34be365a55a5e1d6e682fb3403b71ac889 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 6 Jul 2024 09:33:42 +0100 Subject: [PATCH] test(http): line folding (#1064) Signed-off-by: Rudi Grinberg --- http/test/expect/dune | 6 ++++++ http/test/expect/http_tests.ml | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 http/test/expect/dune create mode 100644 http/test/expect/http_tests.ml diff --git a/http/test/expect/dune b/http/test/expect/dune new file mode 100644 index 000000000..af3982008 --- /dev/null +++ b/http/test/expect/dune @@ -0,0 +1,6 @@ +(library + (name http_tests) + (libraries http) + (inline_tests) + (preprocess + (pps ppx_expect))) diff --git a/http/test/expect/http_tests.ml b/http/test/expect/http_tests.ml new file mode 100644 index 000000000..1de8cc1bb --- /dev/null +++ b/http/test/expect/http_tests.ml @@ -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 |}]