ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
multipart.h File Reference

In-place multipart/form-data parser (RFC 7578). More...

Go to the source code of this file.

Classes

struct  MultipartPart
 One parsed part from a multipart body. More...
struct  MultipartBody
 Container for all parsed parts of a multipart body. More...
struct  MultipartNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...

Functions

 PROTOCORE_NS_LAYOUT (MultipartNs, parse, get_field)
embed_bool protocore_multipart_parse (const uint8_t *work, HttpReq *req, MultipartBody *mp)
 Scan req's body as multipart/form-data, reading the boundary from.
const char * protocore_multipart_get_field (const uint8_t *work, const MultipartBody *mp, const char *field)
 The data pointer of the first part whose name matches field, or.

Variables

PROTOCORE_NS MultipartNs Multipart PROTOCORE_UNUSED
 Module namespace.

Detailed Description

In-place multipart/form-data parser (RFC 7578).

Parses the body already stored in HttpReq::body[]. The parser modifies the body buffer in-place by inserting null terminators, so part->data pointers are valid only while the HttpReq lives (before http_reset()).

The scan is length-bounded over HttpReq::body_len and matches the full \r\n--boundary delimiter (RFC 2046), so a binary part is safe: embedded NUL bytes and even the raw boundary string inside the payload do not truncate it (only the true CRLF--boundary delimiter ends a part). Read a binary part via part->data + part->data_len (the in-place NUL terminator is a convenience for text parts, not a length).

Limitations

  • Maximum parts: MAX_MULTIPART_PARTS (default 4).
  • Maximum total body size: BODY_BUF_SIZE bytes.
  • Only name and filename are extracted from Content-Disposition; other parameters are ignored.
  • Boundary value must be ≤ MAX_BOUNDARY_LEN bytes (RFC 2046 cap: 70).

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file multipart.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( MultipartNs ,
parse ,
get_field  )

◆ protocore_multipart_parse()

embed_bool protocore_multipart_parse ( const uint8_t * work,
HttpReq * req,
MultipartBody * mp )

Scan req's body as multipart/form-data, reading the boundary from.

Parameters
workPROTOCORE_MULTIPART_BORROW bytes the caller took. Not held past the call.
reqReq
mpMp
Returns
EMBED_TRUE on success.

◆ protocore_multipart_get_field()

const char * protocore_multipart_get_field ( const uint8_t * work,
const MultipartBody * mp,
const char * field )

The data pointer of the first part whose name matches field, or.

Parameters
workPROTOCORE_MULTIPART_BORROW bytes the caller took. Not held past the call.
mpMp
fieldField
Returns
The const char *.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS MultipartNs Multipart PROTOCORE_UNUSED
Initial value:
const char * protocore_multipart_get_field(const uint8_t *work, const MultipartBody *mp, const char *field)
The data pointer of the first part whose name matches field, or.
embed_bool protocore_multipart_parse(const uint8_t *work, HttpReq *req, MultipartBody *mp)
Scan req's body as multipart/form-data, reading the boundary from.

Module namespace.

Definition at line 98 of file multipart.h.