MultipartFormData

MultipartFormData :: # (opaque)

Decode bounded HTML form request bodies.

Read a request body through Server.Body with an application-appropriate limit before calling these parsers. Multipart values remain byte lists so file contents and non-UTF-8 fields are preserved.

body = request.body().with_limit(2 * 1024 * 1024).read_all!()?
parts = MultipartFormData.parse_multipart_form_data({
    headers: request.headers(),
    body,
})?

Multipart parsing implements the conventional subset of RFC 7578.

parse_form_url_encoded : List(U8) -> Try(Dict(Str, Str), [BadUtf8, InvalidPercentEncoding])

Decode an application/x-www-form-urlencoded body.

Plus signs become spaces and percent escapes are decoded before UTF-8 validation. A later duplicate key replaces an earlier value.

parse_multipart_form_data : { headers : List(Header), body : List(U8) } -> Try(List(FormData), [InvalidMultipartFormData, ExpectedContentTypeHeader, InvalidContentTypeHeader])

Decode a complete multipart/form-data body and its request headers.