4#include "../Foundation/Result.h"
5#include "../Foundation/Span.h"
6#include "../Foundation/StringSpan.h"
52 char boundaryStorage[71] = {0};
53 char boundaryBuffer[128] = {0};
55 size_t tokenStart = 0;
56 size_t tokenLength = 0;
57 size_t globalStart = 0;
58 size_t globalLength = 0;
59 size_t matchIndex = 0;
61 int topLevelCoroutine = 0;
62 int nestedParserCoroutine = 0;
64 uint8_t boundaryMatchIndex = 0;
69 [[nodiscard]]
bool parseBoundary(
char currentChar);
70 [[nodiscard]]
bool parseHeaders(
char currentChar);
71 [[nodiscard]]
bool parseBody(
char currentChar);
74 [[nodiscard]]
bool parsePreamble(
char currentChar);
75 [[nodiscard]]
bool parseBoundaryLine(
char currentChar);
76 [[nodiscard]]
bool parseHeaderName(
char currentChar);
77 [[nodiscard]]
bool parseHeaderValue(
char currentChar);
78 [[nodiscard]]
bool parseBodyUntilBoundary(
char currentChar);
80 template <
bool (HttpMultipartParser::*Func)(
char), Token currentResult>
81 Result process(Span<const char>& data,
size_t& readBytes, Span<const char>& parsedData);
Incremental HTTP multipart/form-data parser.
Definition HttpMultipartParser.h:15
void reset()
Resets the parser state.
Result parse(Span< const char > data, size_t &readBytes, Span< const char > &parsedData)
Parse an incoming chunk of bytes, returning actually parsed span.
Result initWithBoundary(StringSpan boundary)
Initializes the parser with the given boundary (that excludes the leading '–')
State
State of the parser.
Definition HttpMultipartParser.h:24
Token
One possible Token reported by the parser.
Definition HttpMultipartParser.h:32
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:13
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:37