Incremental HTTP request or response parser. More...
#include <HttpParser.h>
Public Types | |
| enum class | Method { HttpGET , HttpPUT , HttpPOST } |
| Method of the current request / response. More... | |
| enum class | State { Parsing , Result , Finished } |
| State of the parser. More... | |
| enum class | Token { Method , Url , Version , HeaderName , HeaderValue , HeadersEnd , StatusCode , StatusString , Body } |
| One possible Token reported by the parser. More... | |
| enum class | Type { Request , Response } |
| Type of the stream to be parsed (Request or Response) More... | |
| enum class | HeaderType { ContentLength = 0 } |
| Header types. More... | |
Public Member Functions | |
| Result | parse (Span< const char > data, size_t &readBytes, Span< const char > &parsedData) |
| Parse an incoming chunk of bytes, returning actually parsed span. | |
| bool | matchesHeader (HeaderType headerName) const |
| Check if current result matches this HeaderType. | |
Public Attributes | |
| Method | method = Method::HttpGET |
| Http method. | |
| size_t | tokenStart = 0 |
| Offset in bytes to start of parsed token. | |
| size_t | tokenLength = 0 |
| Length in bytes of parsed token. | |
| uint32_t | statusCode = 0 |
| Parsed http status code. | |
| uint64_t | contentLength = 0 |
| Content-Length of http request. | |
| Token | token = Token::HeadersEnd |
| Last found result. | |
| State | state = State::Parsing |
| Current state of the parser. | |
| Type | type = Type::Request |
| Type of http stream (request or response) | |
Incremental HTTP request or response parser.
|
strong |
|
strong |
|
strong |
|
strong |
One possible Token reported by the parser.
|
strong |
|
nodiscard |
Check if current result matches this HeaderType.
| Result SC::HttpParser::parse | ( | Span< const char > | data, |
| size_t & | readBytes, | ||
| Span< const char > & | parsedData ) |
Parse an incoming chunk of bytes, returning actually parsed span.
| data | Incoming chunk of bytes to be parsed |
| readBytes | Number of bytes actually read |
| parsedData | A sub-span of data pointing at the actually parsed data |
| uint64_t SC::HttpParser::contentLength = 0 |
Content-Length of http request.
| Method SC::HttpParser::method = Method::HttpGET |
Http method.
| State SC::HttpParser::state = State::Parsing |
Current state of the parser.
| uint32_t SC::HttpParser::statusCode = 0 |
Parsed http status code.
| Token SC::HttpParser::token = Token::HeadersEnd |
Last found result.
| size_t SC::HttpParser::tokenLength = 0 |
Length in bytes of parsed token.
| size_t SC::HttpParser::tokenStart = 0 |
Offset in bytes to start of parsed token.
| Type SC::HttpParser::type = Type::Request |
Type of http stream (request or response)