|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
In-place multipart/form-data parser (RFC 7578). More...
#include "network_drivers/presentation/http/http_parser/http_parser.h"#include "protocore_config.h"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) | |
| proto_bool | protocore_multipart_parse (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 (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. | |
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
MAX_MULTIPART_PARTS (default 4).BODY_BUF_SIZE bytes.name and filename are extracted from Content-Disposition; other parameters are ignored.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.
Definition in file multipart.h.
| PROTOCORE_NS_LAYOUT | ( | MultipartNs | , |
| parse | , | ||
| get_field | |||
| ) |
| proto_bool protocore_multipart_parse | ( | uint8_t * | work, |
| HttpReq * | req, | ||
| MultipartBody * | mp | ||
| ) |
Scan req's body as multipart/form-data, reading the boundary from.
| work | PROTOCORE_MULTIPART_BORROW bytes the caller took. Not held past the call. |
| req | Req |
| mp | Mp |
| const char * protocore_multipart_get_field | ( | uint8_t * | work, |
| const MultipartBody * | mp, | ||
| const char * | field | ||
| ) |
The data pointer of the first part whose name matches field, or.
| work | PROTOCORE_MULTIPART_BORROW bytes the caller took. Not held past the call. |
| mp | Mp |
| field | Field |
| PROTOCORE_NS MultipartNs Multipart PROTOCORE_UNUSED |
Module namespace.
Definition at line 98 of file multipart.h.