SNode.C
|
#include <ResponseParser.h>
Public Member Functions | |
ResponseParser (core::socket::stream::SocketContext *socketContext, const std::function< void()> &onResponseStart, const std::function< void(Response &&)> &onResponseParsed, const std::function< void(int, const std::string &)> &onResponseParseError) | |
ResponseParser (const ResponseParser &)=delete | |
ResponseParser & | operator= (const ResponseParser &)=delete |
Response && | getResponse () |
![]() | |
Parser (core::socket::stream::SocketContext *socketContext, const enum HTTPCompliance &compliance=HTTPCompliance::RFC2616|HTTPCompliance::RFC7230) | |
virtual | ~Parser () |
std::size_t | parse () |
void | reset () |
Private Member Functions | |
void | begin () override |
void | parseStartLine (const std::string &line) override |
void | analyzeHeader () override |
void | parsingFinished () override |
void | parseError (int code, const std::string &reason) override |
Private Attributes | |
Response | response |
std::function< void()> | onResponseStart |
std::function< void(Response &&)> | onResponseParsed |
std::function< void(int, const std::string &)> | onResponseParseError |
Additional Inherited Members | |
![]() | |
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 } |
![]() | |
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 const std::regex | httpVersionRegex |
Definition at line 63 of file ResponseParser.h.
web::http::client::ResponseParser::ResponseParser | ( | core::socket::stream::SocketContext * | socketContext, |
const std::function< void()> & | onResponseStart, | ||
const std::function< void(Response &&)> & | onResponseParsed, | ||
const std::function< void(int, const std::string &)> & | onResponseParseError | ||
) |
Definition at line 59 of file ResponseParser.cpp.
References onResponseParsed, onResponseParseError, onResponseStart, and web::http::Parser::Parser().
Referenced by apps::http::getResponseParser(), and web::http::client::SocketContext::SocketContext().
|
delete |
|
overrideprivatevirtual |
Reimplemented from web::http::Parser.
Definition at line 110 of file ResponseParser.cpp.
References web::http::Parser::analyzeHeader(), web::http::Parser::BODY, web::http::ciContains(), web::http::Close, web::http::client::Response::connectionState, web::http::Parser::contentLength, web::http::CookieOptions::CookieOptions(), web::http::client::Response::cookies, web::http::Parser::headers, web::http::Identity, web::http::Keep, web::http::Parser::parserState, parsingFinished(), response, web::http::CookieOptions::setOption(), httputils::str_split(), httputils::str_trimm(), and web::http::Parser::transferEncoding.
|
overrideprivatevirtual |
Implements web::http::Parser.
Definition at line 77 of file ResponseParser.cpp.
References onResponseStart.
Response && web::http::client::ResponseParser::getResponse | ( | ) |
Definition at line 69 of file ResponseParser.cpp.
References web::http::client::Response::body, web::http::Parser::decoderQueue, web::http::ContentDecoder::getContent(), and response.
Referenced by web::http::client::SocketContext::onDisconnected().
|
delete |
|
overrideprivatevirtual |
Implements web::http::Parser.
Definition at line 181 of file ResponseParser.cpp.
References web::http::Parser::ERROR, onResponseParseError, web::http::Parser::parserState, and web::http::Parser::reset().
Referenced by parseStartLine().
|
overrideprivatevirtual |
Implements web::http::Parser.
Definition at line 81 of file ResponseParser.cpp.
References web::http::StatusCode::contains(), web::http::Parser::HEADER, web::http::Parser::httpMajor, web::http::Parser::httpMinor, web::http::client::Response::httpVersion, web::http::Parser::httpVersionRegex, parseError(), web::http::Parser::parserState, web::http::client::Response::reason, response, web::http::client::Response::statusCode, and httputils::str_split().
|
overrideprivatevirtual |
Implements web::http::Parser.
Definition at line 168 of file ResponseParser.cpp.
References web::http::Parser::BEGIN, web::http::client::Response::body, web::http::Parser::content, web::http::client::Response::headers, web::http::Parser::headers, web::http::client::Response::httpMajor, web::http::Parser::httpMajor, web::http::client::Response::httpMinor, web::http::Parser::httpMinor, onResponseParsed, web::http::Parser::parserState, web::http::Parser::reset(), and response.
Referenced by analyzeHeader().
|
private |
Definition at line 91 of file ResponseParser.h.
Referenced by parsingFinished(), and ResponseParser().
|
private |
Definition at line 92 of file ResponseParser.h.
Referenced by parseError(), and ResponseParser().
|
private |
Definition at line 90 of file ResponseParser.h.
Referenced by begin(), and ResponseParser().
|
private |
Definition at line 87 of file ResponseParser.h.
Referenced by analyzeHeader(), getResponse(), parseStartLine(), and parsingFinished().