mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
24 lines
627 B
OCaml
24 lines
627 B
OCaml
open Test_util
|
|
open Tiny_httpd_core.IO
|
|
|
|
let spf = Printf.sprintf
|
|
|
|
(* one chunk *)
|
|
let () =
|
|
let io = Input.of_string "5\r\nhello\r\n0\r\n\r\nARGH" in
|
|
let str =
|
|
io
|
|
|> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith
|
|
|> Input.read_all_using ~buf:(Buf.create ())
|
|
in
|
|
assert_eq ~to_string:(spf "%S") "hello" str
|
|
|
|
(* two chunks *)
|
|
let () =
|
|
let io = Input.of_string "5\r\nhello\r\n6\r\n world\r\n0\r\n\r\nARGH" in
|
|
let str =
|
|
io
|
|
|> Input.read_chunked ~bytes:(Bytes.create 4) ~fail:failwith
|
|
|> Input.read_all_using ~buf:(Buf.create ())
|
|
in
|
|
assert_eq ~to_string:(spf "%S") "hello world" str
|