Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose read_buffer_size in parts #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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