Skip to content

Commit

Permalink
expose read_buffer_size in parts
Browse files Browse the repository at this point in the history
  • Loading branch information
rizo committed Jun 19, 2024
1 parent c90fe84 commit 4d820ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/http_multipart_formdata.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ())

Expand Down
7 changes: 4 additions & 3 deletions lib/http_multipart_formdata.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4d820ad

Please sign in to comment.