Page
Library
Module
Module type
Parameter
Class
Class type
Source
Http_multipart_formdata
SourceHttp_multipart_formdata
is a non-blocking, streaming HTTP multipart formdata parser. Its design is based on two main ideas:
The parser implements HTTP multipart/form-data
standard as defined in RFC 7578.
reader
represents a HTTP multipart formdata reader.
and read = [
| `End
The reader has completed reading.
*)| `Header of part_header
Multipart part header data.
*)| `Body of Cstruct.t
Multipart part body data.
*)| `Body_end
reader
has completed reading the Multipart body data.
| `Awaiting_input of [ `Cstruct of Cstruct.t | `Eof ] -> read
The reader is waiting for it to be provided with input data. This is only returned when `Incremental
is chosen as input
.
| `Error of string
]
Represents a parsed multipart part header data.
Represents the multipart boundary value.
boundary content_type
parses content_type
to extract boundary
value. content_type
is the HTTP request Content-Type
header value.
let content_type =
"multipart/form-data; \
boundary=---------------------------735323031399963166993862150"
in
Http_multipart_formdata.boundary content_type
reader ?read_buffer_size boundary input
creates reader. The default value for read_buffer_size
is 1KB.
read_part ?read_body_len ~boundary reader
reads a http multipart body and returns a read
value.
uncoonsumed rader
returns any leftover data still remaining after reader
returns `End
.
name t
returns the form field name
content_type t
returns the part content-type.
filename t
returns the uploaded filename is the multipart is a file
param_value name t
returns the multipart parameter value with name name
.