function parseFormBody
Since 0.5.0
parseFormBody(
body: Uint8Array,
contentType: string | null
): FormBody

Parses one request body as a form — the ONE parse all three IRequest.formData?() implementations share, and the function every fallback path (a request without the optional accessor) calls directly.

The urlencoded arm is URLSearchParams over the decoded body, which equals the web answer value for value, including empty values and repeated names in wire order. The multipart arm is the promoted parseMultipart, with a part's file-versus-text nature taken from filename !== undefined and its text parts decoded as UTF-8.

Parameters

The raw request bytes

contentType: string | null

The request's content-type header, or null when absent

Return Type

The parsed form

Throws

UnsupportedFormEncodingError

When contentType is neither form encoding — a JSON body, a missing content-type, or a multipart type with no boundary=. A multipart BODY that is unparseable is NOT a throw: it yields an empty FormBody, which is the promoted parser's released behaviour and is documented as the accessor's limit rather than hidden behind a status.

Usage

import { parseFormBody } from "common/src/index.ts";