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 | Result { Method , Url , Version , HeaderName , HeaderValue , HeadersEnd , StatusCode , StatusString , Body } |
One possible Result 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 | |
SC::Result | parse (Span< const char > data, size_t &readBytes, Span< const char > &parsedData) |
Parse an incoming chunk of bytes, returning actually parsed span. More... | |
bool | matchesHeader (HeaderType headerName) const |
Check if current result matches this HeaderType. More... | |
Public Attributes | |
Method | method = Method::HttpGET |
Http method. More... | |
size_t | tokenStart = 0 |
Offset in bytes to start of parsed token. More... | |
size_t | tokenLength = 0 |
Length in bytes of parsed token. More... | |
uint32_t | statusCode = 0 |
Parsed http status code. More... | |
uint64_t | contentLength = 0 |
Content-Length of http request. More... | |
Result | result = Result::HeadersEnd |
Last found result. More... | |
State | state = State::Parsing |
Current state of the parser. More... | |
Type | type = Type::Request |
Type of http stream (request or response) More... | |
Incremental HTTP request or response parser.
|
strong |
|
strong |
|
strong |
One possible Result reported by the parser.
|
strong |
|
strong |
bool SC::HttpParser::matchesHeader | ( | HeaderType | headerName | ) | const |
Check if current result matches this HeaderType.
SC::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.
Result SC::HttpParser::result = Result::HeadersEnd |
Last found result.
State SC::HttpParser::state = State::Parsing |
Current state of the parser.
uint32_t SC::HttpParser::statusCode = 0 |
Parsed http status code.
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)