DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
multipart.cpp File Reference

In-place multipart/form-data parser implementation. More...

#include "multipart.h"
#include <string.h>

Go to the source code of this file.

Functions

bool multipart_parse (HttpReq *req, Multipart *mp)
 Parse the body of req as multipart/form-data.
 
const char * multipart_get_field (const Multipart *mp, const char *field)
 Look up a field value across all parsed parts by name.
 

Detailed Description

In-place multipart/form-data parser implementation.

Definition in file multipart.cpp.

Function Documentation

◆ multipart_parse()

bool multipart_parse ( HttpReq req,
Multipart mp 
)

Parse the body of req as multipart/form-data.

Reads the boundary from the Content-Type header, then scans req->body in-place, null-terminating each part's headers and data.

Parameters
reqFully-parsed HTTP request (must be in PARSE_COMPLETE state).
mpOutput structure; filled on success.
Returns
true if at least one part was found, false on parse error.

Definition at line 39 of file multipart.cpp.

References HttpReq::body, MultipartPart::data, MultipartPart::data_len, MultipartPart::filename, http_get_header(), MAX_BOUNDARY_LEN, MAX_MULTIPART_PARTS, MultipartPart::name, Multipart::part_count, Multipart::parts, and MultipartPart::type.

◆ multipart_get_field()

const char * multipart_get_field ( const Multipart mp,
const char *  field 
)

Look up a field value across all parsed parts by name.

Returns the data pointer of the first part whose name matches field. Useful for simple form submissions where each field has a unique name.

Parameters
mpParsed multipart result.
fieldForm field name to search for.
Returns
Part data (null-terminated), or nullptr if not found.

Definition at line 152 of file multipart.cpp.

References MultipartPart::data, MultipartPart::name, Multipart::part_count, and Multipart::parts.