From 4d820ad1191ec352d5eeac5fd98aa01c9a0122c6 Mon Sep 17 00:00:00 2001 From: Rizo Date: Wed, 19 Jun 2024 14:54:44 +0100 Subject: [PATCH] expose `read_buffer_size` in parts --- lib/http_multipart_formdata.ml | 4 ++-- lib/http_multipart_formdata.mli | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/http_multipart_formdata.ml b/lib/http_multipart_formdata.ml index dab7b8e..1dc23ce 100644 --- a/lib/http_multipart_formdata.ml +++ b/lib/http_multipart_formdata.ml @@ -348,7 +348,7 @@ let unconsumed reader = reader.unconsumed (* Non streaming *) -let parts boundary body = +let parts ?(read_buffer_size = 10) boundary body = let rec read_parts reader parts = read reader |> function @@ -374,7 +374,7 @@ let parts boundary body = | _ -> assert false in let reader = - reader ~read_buffer_size:10 boundary (`Cstruct (Cstruct.of_string body)) + reader ~read_buffer_size boundary (`Cstruct (Cstruct.of_string body)) in read_parts reader (Queue.create ()) diff --git a/lib/http_multipart_formdata.mli b/lib/http_multipart_formdata.mli index 14eca06..145c0d8 100644 --- a/lib/http_multipart_formdata.mli +++ b/lib/http_multipart_formdata.mli @@ -89,11 +89,12 @@ val unconsumed : reader -> Cstruct.t size. *) val parts : - boundary + ?read_buffer_size:int + -> boundary -> string -> ((field_name * (part_header * part_body)) list, string) result -(** [parts boundary http_body] returns a list of HTTP multipart parts parsed in - [http_body]. +(** [parts ?read_buffer_size boundary http_body] returns a list of HTTP + multipart parts parsed in [http_body]. The returned parts list is keyed to a form field name so that one can do: