SNode.C
|
#include <Parser.h>
Public Member Functions | |
Parser (core::socket::stream::SocketContext *socketContext, const enum HTTPCompliance &compliance=HTTPCompliance::RFC2616|HTTPCompliance::RFC7230) | |
virtual | ~Parser () |
std::size_t | parse () |
void | reset () |
Protected Types | |
enum struct | HTTPCompliance : unsigned short { RFC1945 = 0x01 << 0 , RFC2616 = 0x01 << 1 , RFC7230 = 0x01 << 2 , RFC7231 = 0x01 << 3 , RFC7232 = 0x01 << 4 , RFC7233 = 0x01 << 5 , RFC7234 = 0x01 << 6 , RFC7235 = 0x01 << 7 , RFC7540 = 0x01 << 8 , RFC7541 = 0x01 << 9 } |
enum struct | ParserState { BEGIN , FIRSTLINE , HEADER , BODY , TRAILER , ERROR } |
Protected Member Functions | |
virtual void | analyzeHeader () |
Protected Attributes | |
enum web::http::Parser::HTTPCompliance | hTTPCompliance |
ParserState | parserState = ParserState::BEGIN |
TransferEncoding | transferEncoding = TransferEncoding::HTTP10 |
CiStringMap< std::string > | headers |
std::vector< char > | content |
int | httpMajor = 0 |
int | httpMinor = 0 |
std::list< web::http::ContentDecoder * > | decoderQueue |
core::socket::stream::SocketContext * | socketContext = nullptr |
std::string | line |
std::size_t | contentLength = 0 |
std::size_t | contentLengthRead = 0 |
Static Protected Attributes | |
static const std::regex | httpVersionRegex |
Private Member Functions | |
virtual void | begin ()=0 |
virtual void | parseStartLine (const std::string &line)=0 |
virtual void | parseError (int code, const std::string &reason)=0 |
virtual void | parsingFinished ()=0 |
std::size_t | readStartLine () |
std::size_t | readHeader () |
std::size_t | readContent () |
std::size_t | readTrailer () |
Private Attributes | |
web::http::decoder::Fields | headerDecoder |
std::set< std::string > | trailerFieldsExpected |
web::http::decoder::Fields | trailerDecoder |
Friends | |
enum HTTPCompliance | operator| (const enum HTTPCompliance &c1, const enum HTTPCompliance &c2) |
enum HTTPCompliance | operator& (const enum HTTPCompliance &c1, const enum HTTPCompliance &c2) |
|
strongprotected |
Enumerator | |
---|---|
RFC1945 | |
RFC2616 | |
RFC7230 | |
RFC7231 | |
RFC7232 | |
RFC7233 | |
RFC7234 | |
RFC7235 | |
RFC7540 | |
RFC7541 |
|
strongprotected |
|
explicit |
Definition at line 63 of file Parser.cpp.
References web::http::decoder::Fields::Fields(), headerDecoder, socketContext, and trailerDecoder.
Referenced by web::http::server::RequestParser::RequestParser(), and web::http::client::ResponseParser::ResponseParser().
|
virtual |
Definition at line 70 of file Parser.cpp.
References reset().
|
protectedvirtual |
Reimplemented in web::http::client::ResponseParser, and web::http::server::RequestParser.
Definition at line 160 of file Parser.cpp.
References web::http::decoder::Chunked::Chunked(), web::http::Chunked, web::http::ciContains(), contentLength, decoderQueue, headers, web::http::HTTP10, web::http::decoder::HTTP10Response::HTTP10Response(), web::http::decoder::Identity::Identity(), web::http::Identity, web::http::decoder::Fields::setFieldsExpected(), socketContext, httputils::str_split(), httputils::str_trimm(), trailerDecoder, trailerFieldsExpected, and transferEncoding.
Referenced by web::http::client::ResponseParser::analyzeHeader(), web::http::server::RequestParser::analyzeHeader(), and readHeader().
|
privatepure virtual |
Implemented in web::http::client::ResponseParser, and web::http::server::RequestParser.
Referenced by parse().
std::size_t web::http::Parser::parse | ( | ) |
Definition at line 92 of file Parser.cpp.
References BEGIN, begin(), BODY, ERROR, FIRSTLINE, HEADER, parserState, readContent(), readHeader(), readStartLine(), readTrailer(), and TRAILER.
Referenced by apps::http::SimpleSocketProtocol::onReceivedFromPeer(), web::http::client::SocketContext::onReceivedFromPeer(), and web::http::server::SocketContext::onReceivedFromPeer().
|
privatepure virtual |
Implemented in web::http::client::ResponseParser, and web::http::server::RequestParser.
Referenced by readContent(), readHeader(), and readTrailer().
|
privatepure virtual |
Implemented in web::http::client::ResponseParser, and web::http::server::RequestParser.
Referenced by readStartLine().
|
privatepure virtual |
Implemented in web::http::client::ResponseParser, and web::http::server::RequestParser.
Referenced by readContent(), and readTrailer().
|
private |
Definition at line 219 of file Parser.cpp.
References web::http::Chunked, content, decoderQueue, web::http::ContentDecoder::getContent(), headers, web::http::ContentDecoder::isComplete(), web::http::ContentDecoder::isError(), parseError(), parserState, parsingFinished(), web::http::ContentDecoder::read(), TRAILER, and transferEncoding.
Referenced by parse().
|
private |
Definition at line 147 of file Parser.cpp.
References analyzeHeader(), web::http::decoder::Fields::getErrorCode(), web::http::decoder::Fields::getErrorReason(), web::http::decoder::Fields::getHeader(), headerDecoder, headers, web::http::decoder::Fields::isComplete(), web::http::decoder::Fields::isError(), parseError(), and web::http::decoder::Fields::read().
Referenced by parse().
|
private |
Definition at line 123 of file Parser.cpp.
References FIRSTLINE, line, parserState, parseStartLine(), core::socket::stream::SocketContext::readFromPeer(), and socketContext.
Referenced by parse().
|
private |
Definition at line 242 of file Parser.cpp.
References web::http::decoder::Fields::getErrorCode(), web::http::decoder::Fields::getErrorReason(), web::http::decoder::Fields::getHeader(), headers, web::http::decoder::Fields::isComplete(), web::http::decoder::Fields::isError(), parseError(), parsingFinished(), web::http::decoder::Fields::read(), and trailerDecoder.
Referenced by parse().
void web::http::Parser::reset | ( | ) |
Definition at line 74 of file Parser.cpp.
References BEGIN, content, contentLength, contentLengthRead, decoderQueue, headers, httpMajor, httpMinor, line, parserState, and trailerFieldsExpected.
Referenced by web::http::client::ResponseParser::parseError(), web::http::server::RequestParser::parseError(), web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), and ~Parser().
|
friend |
Definition at line 260 of file Parser.cpp.
|
friend |
Definition at line 256 of file Parser.cpp.
|
protected |
Definition at line 120 of file Parser.h.
Referenced by web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), readContent(), and reset().
|
protected |
Definition at line 143 of file Parser.h.
Referenced by analyzeHeader(), web::http::client::ResponseParser::analyzeHeader(), web::http::server::RequestParser::analyzeHeader(), and reset().
|
protected |
|
protected |
Definition at line 125 of file Parser.h.
Referenced by analyzeHeader(), web::http::client::ResponseParser::getResponse(), readContent(), and reset().
|
private |
Definition at line 130 of file Parser.h.
Referenced by Parser(), and readHeader().
|
protected |
Definition at line 119 of file Parser.h.
Referenced by analyzeHeader(), web::http::client::ResponseParser::analyzeHeader(), web::http::server::RequestParser::analyzeHeader(), web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), readContent(), readHeader(), readTrailer(), and reset().
|
protected |
|
protected |
Definition at line 122 of file Parser.h.
Referenced by web::http::client::ResponseParser::parseStartLine(), web::http::server::RequestParser::parseStartLine(), web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), and reset().
|
protected |
Definition at line 123 of file Parser.h.
Referenced by web::http::client::ResponseParser::parseStartLine(), web::http::server::RequestParser::parseStartLine(), web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), and reset().
|
staticprotected |
Definition at line 104 of file Parser.h.
Referenced by web::http::client::ResponseParser::parseStartLine(), and web::http::server::RequestParser::parseStartLine().
|
protected |
Definition at line 142 of file Parser.h.
Referenced by readStartLine(), and reset().
|
protected |
Definition at line 100 of file Parser.h.
Referenced by web::http::client::ResponseParser::analyzeHeader(), web::http::server::RequestParser::analyzeHeader(), parse(), web::http::client::ResponseParser::parseError(), web::http::server::RequestParser::parseError(), web::http::client::ResponseParser::parseStartLine(), web::http::server::RequestParser::parseStartLine(), web::http::client::ResponseParser::parsingFinished(), web::http::server::RequestParser::parsingFinished(), readContent(), readStartLine(), and reset().
|
protected |
Definition at line 127 of file Parser.h.
Referenced by analyzeHeader(), Parser(), and readStartLine().
|
private |
Definition at line 133 of file Parser.h.
Referenced by analyzeHeader(), Parser(), and readTrailer().
|
private |
Definition at line 132 of file Parser.h.
Referenced by analyzeHeader(), and reset().
|
protected |
Definition at line 102 of file Parser.h.
Referenced by analyzeHeader(), web::http::client::ResponseParser::analyzeHeader(), web::http::server::RequestParser::analyzeHeader(), and readContent().