package http-multipart-formdata

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parsing boundary value

type boundary = string

Represents the multipart boundary value.

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

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

module Part_header : sig ... end

Represents a parsed multipart part header data.

Parsing multi-parts

type on_part_cb = Part_header.t -> part_body_stream:char Lwt_stream.t -> unit Lwt.t

on_part_cb represents the callback function which is called by the parse functions to process multipart parts.

type http_body = [
  1. | `Stream of char Lwt_stream.t
  2. | `Fd of Lwt_unix.file_descr
  3. | `Channel of Lwt_io.input_channel
]

http_body represents various HTTP POST body stream.

val parse_parts : ?part_stream_chunk_size:int -> boundary:boundary -> on_part:on_part_cb -> http_body -> (unit, string) Stdlib.result Lwt.t

parse_parts ?part_stream_chunk_size ~boundary ~on_part http_body functions with various input types.

  • part_stream_chunk_size is the maximum number of bytes each chunk holds at any time. The default value is 1048576 or 1MB.
  • boundary is part boundary value. Use parse_boundary to parse boundary value from Content-type header value.
  • on_part is the part handling function
  • http_body is the raw HTTP POST request body content stream.
OCaml

Innovation. Community. Security.