4#include "../Foundation/Result.h"
5#include "../Foundation/Span.h"
24 size_t tokenStart = 0;
25 size_t tokenLength = 0;
51 Token token = Token::HeadersEnd;
79 size_t globalStart = 0;
80 size_t globalLength = 0;
81 int topLevelCoroutine = 0;
82 int nestedParserCoroutine = 0;
83 bool parsedContentLength =
false;
84 size_t matchIndex = 0;
86 static constexpr size_t numMatches = 1;
88 size_t matchingHeader[numMatches] = {0};
89 bool matchingHeaderValid[numMatches] = {
false};
92 [[nodiscard]]
bool parseHeaderName(
char currentChar);
93 [[nodiscard]]
bool parseHeaderValue(
char currentChar);
94 [[nodiscard]]
bool parseStatusCode(
char currentChar);
95 [[nodiscard]]
bool parseNumberValue(
char currentChar);
96 [[nodiscard]]
bool parseHeadersEnd(
char currentChar);
97 [[nodiscard]]
bool parseMethod(
char currentChar);
98 [[nodiscard]]
bool parseUrl(
char currentChar);
100 template <
bool spaces>
101 [[nodiscard]]
bool parseVersion(
char currentChar);
103 template <
bool (HttpParser::*Func)(
char), Token currentResult>
104 Result process(Span<const char>& data,
size_t& readBytes, Span<const char>& parsedData);
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition PrimitiveTypes.h:42
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition PrimitiveTypes.h:38
Incremental HTTP request or response parser.
Definition HttpParser.h:14
State
State of the parser.
Definition HttpParser.h:31
Token
One possible Token reported by the parser.
Definition HttpParser.h:39
HeaderType
Header types.
Definition HttpParser.h:71
Method
Method of the current request / response.
Definition HttpParser.h:17
Result parse(Span< const char > data, size_t &readBytes, Span< const char > &parsedData)
Parse an incoming chunk of bytes, returning actually parsed span.
Type
Type of the stream to be parsed (Request or Response)
Definition HttpParser.h:56
bool matchesHeader(HeaderType headerName) const
Check if current result matches this HeaderType.
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