package http-multipart-formdata

  1. Overview
  2. Docs

Types

type reader
and read_result = [
  1. | `End
  2. | `Header of part_header
  3. | `Body of Cstruct.t
  4. | `Body_end
  5. | `Awaiting_input of [ `Cstruct of Cstruct.t | `Eof ] -> read_result
  6. | `Error of string
]
and input = [
  1. | `Cstruct of Cstruct.t
  2. | `Incremental
]
and part_header

Represents a parsed multipart part header data.

and boundary

Represents the multipart boundary value.

Mulipart Boundary parser

val boundary : string -> (boundary, string) Stdlib.result

boundary content_type parses content_type to extract boundary value. content_type is the HTTP request Content-Type header value.

Multipart Reader

val reader : ?read_buffer_size:int -> boundary -> input -> reader

reader ?read_buffer_size boundary input creates reader. The default value for read_buffer_size is 1KB.

val read_part : reader -> read_result

read_part ?read_body_len ~boundary reader reads a http multipart body and returns a read_result.

val unconsumed : reader -> Cstruct.t

Part header

val name : part_header -> string

name t returns the form field name

val content_type : part_header -> string

content_type t returns the part content-type.

val filename : part_header -> string option

filename t returns the uploaded filename is the multipart is a file

val find : string -> part_header -> string option

param_value name t returns the multipart parameter value with name name.

Pretty Printers

val pp_part_header : Stdlib.Format.formatter -> part_header -> unit
val pp_read_result : Stdlib.Format.formatter -> read_result -> unit
val pp_boundary : Stdlib.Format.formatter -> boundary -> unit
OCaml

Innovation. Community. Security.