4#include "../Common/Result.h"
5#include "../Common/Span.h"
6#include "../Common/StringSpan.h"
30 size_t tokenStart = 0;
31 size_t tokenLength = 0;
32 uint32_t statusCode = 0;
33 uint64_t contentLength = 0;
34 bool connectionKeepAlive =
true;
58 Token token = Token::HeadersEnd;
74 Result
parse(Span<const char> data,
size_t& readBytes, Span<const char>& parsedData);
88 size_t globalStart = 0;
89 size_t globalLength = 0;
90 int topLevelCoroutine = 0;
91 int nestedParserCoroutine = 0;
92 bool parsedContentLength =
false;
93 bool parsedConnection =
false;
94 size_t matchIndex = 0;
96 static constexpr size_t numMatches =
static_cast<size_t>(HeaderType::ContentType) + 1;
98 size_t matchingHeader[numMatches] = {0};
99 bool matchingHeaderValid[numMatches] = {
false};
102 [[nodiscard]]
bool parseHeaderName(
char currentChar);
103 [[nodiscard]]
bool parseHeaderValue(
char currentChar);
104 [[nodiscard]]
bool parseStatusCode(
char currentChar);
105 [[nodiscard]]
bool parseNumberValue(
char currentChar);
106 [[nodiscard]]
bool parseConnectionValue(
char currentChar);
107 [[nodiscard]]
bool parseHeadersEnd(
char currentChar);
108 [[nodiscard]]
bool parseMethod(
char currentChar);
109 [[nodiscard]]
bool parseUrl(
char currentChar);
111 template <
bool spaces>
112 [[nodiscard]]
bool parseVersion(
char currentChar);
114 template <
bool (HttpParser::*Func)(
char), Token currentResult>
115 Result process(Span<const char>& data,
size_t& readBytes, Span<const char>& parsedData);
Incremental HTTP request or response parser.
Definition HttpParser.h:16
State
State of the parser.
Definition HttpParser.h:38
Token
One possible Token reported by the parser.
Definition HttpParser.h:46
HeaderType
Header types.
Definition HttpParser.h:78
Method
Method of the current request / response.
Definition HttpParser.h:19
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:63
bool matchesHeader(HeaderType headerName) const
Check if current result matches this HeaderType.