Skip to main content

Module multipart

Module multipart 

Source
Expand description

Multipart form data parser.

This module provides streaming parsing of multipart/form-data requests, which is the standard encoding for file uploads.

§Format

Multipart form data consists of multiple parts separated by a boundary string:

--boundary\r\n
Content-Disposition: form-data; name="field1"\r\n
\r\n
value1\r\n
--boundary\r\n
Content-Disposition: form-data; name="file"; filename="example.txt"\r\n
Content-Type: text/plain\r\n
\r\n
file contents...\r\n
--boundary--\r\n

§Features

  • Streaming parser that doesn’t buffer entire body
  • Per-file and total size limits
  • Extracts filename, content-type, and field name
  • Memory-safe: enforces limits before allocating

Structs§

MultipartConfig
Configuration for multipart parsing.
MultipartForm
Parsed multipart form data.
MultipartParser
Streaming multipart parser.
Part
A parsed multipart form part.
UploadFile
An uploaded file with metadata.

Enums§

MultipartError
Errors that can occur during multipart parsing.

Constants§

DEFAULT_MAX_FIELDS
Default maximum number of fields.
DEFAULT_MAX_FILE_SIZE
Default maximum file size (10MB).
DEFAULT_MAX_TOTAL_SIZE
Default maximum total upload size (50MB).

Functions§

parse_boundary
Parse boundary from Content-Type header.