|
SNode.C
|
#include <Request.h>
Public Member Functions | |
| MasterRequest (SocketContext *socketContext, const std::string &hostFieldValue) | |
| MasterRequest (MasterRequest &)=delete | |
| MasterRequest (MasterRequest &&) noexcept | |
| MasterRequest & | operator= (MasterRequest &)=delete |
| MasterRequest & | operator= (MasterRequest &&) noexcept=delete |
| ~MasterRequest () override | |
| void | init () |
| bool | send (const char *chunk, std::size_t chunkLen, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onResponseReceived, const std::function< void(const std::shared_ptr< Request > &, const std::string &)> &onResponseParseError) |
| bool | send (const std::string &chunk, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onResponseReceived, const std::function< void(const std::shared_ptr< Request > &, const std::string &)> &onResponseParseError) |
| bool | upgrade (const std::string &url, const std::string &protocols, const std::function< void(bool)> &onUpgradeInitiate, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, bool)> &onResponseReceived, const std::function< void(const std::shared_ptr< Request > &, const std::string &)> &onResponseParseError) |
| bool | sendFile (const std::string &file, const std::function< void(int errnum)> &onStatus, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onResponseReceived, const std::function< void(const std::shared_ptr< Request > &, const std::string &)> &onResponseParseError) |
| MasterRequest & | sendHeader () |
| MasterRequest & | sendFragment (const char *chunk, std::size_t chunkLen) |
| MasterRequest & | sendFragment (const std::string &data) |
| bool | end (const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onResponseReceived, const std::function< void(const std::shared_ptr< Request > &, const std::string &)> &onResponseParseError) |
| bool | requestEventSource (const std::string &url, const std::function< std::size_t()> &onServerSentEvent, const std::function< void()> &onOpen, const std::function< void()> &onError) |
Public Member Functions inherited from web::http::client::Request | |
| Request (SocketContext *socketContext, const std::string &host) | |
| Request (Request &)=delete | |
| Request & | operator= (Request &)=delete |
| Request & | operator= (Request &&) noexcept=delete |
| void | setMasterRequest (const std::shared_ptr< MasterRequest > &masterRequest) |
| std::shared_ptr< MasterRequest > | getMasterRequest () const |
| SocketContext * | getSocketContext () const |
| Request & | host (const std::string &hostFieldValue) |
| Request & | append (const std::string &field, const std::string &value) |
| Request & | set (const std::string &field, const std::string &value, bool overwrite=true) |
| Request & | set (const std::map< std::string, std::string > &headers, bool overwrite=true) |
| Request & | type (const std::string &type) |
| Request & | cookie (const std::string &name, const std::string &value) |
| Request & | cookie (const std::map< std::string, std::string > &cookies) |
| Request & | query (const std::string &key, const std::string &value) |
| Request & | setTrailer (const std::string &field, const std::string &value, bool overwrite=true) |
| std::string | header (const std::string &field) const |
| const CiStringMap< std::string > & | getQueries () const |
| const CiStringMap< std::string > & | getHeaders () const |
| const CiStringMap< std::string > & | getTrailer () const |
| const CiStringMap< std::string > & | getCookies () const |
Public Member Functions inherited from core::pipe::Sink | |
| Sink (Sink &)=delete | |
| Sink & | operator= (Sink &)=delete |
Private Member Functions | |
| bool | initiate (const std::shared_ptr< MasterRequest > &request) |
| bool | executeSendFile (const std::string &file, const std::function< void(int)> &onStatus) |
| bool | executeUpgrade (const std::string &url, const std::string &protocols, const std::function< void(bool)> &onStatus) |
| bool | executeSendHeader () |
| bool | executeSendFragment (const char *chunk, std::size_t chunkLen) |
| bool | executeEnd () |
| bool | executeSse () |
| void | requestPrepared (const std::shared_ptr< MasterRequest > &request) |
| void | requestDelivered () |
| void | deliverResponse (const std::shared_ptr< MasterRequest > &request, const std::shared_ptr< Response > &response) |
| void | deliverResponseParseError (const std::shared_ptr< MasterRequest > &request, const std::string &message) |
| void | onSourceConnect (core::pipe::Source *source) override |
| void | onSourceData (const char *chunk, std::size_t chunkLen) override |
| void | onSourceEof () override |
| void | onSourceError (int errnum) override |
Private Attributes | |
| std::list< RequestCommand * > | requestCommands |
| std::size_t | contentLengthSent = 0 |
| std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> | onResponseReceived |
| std::function< void(const std::shared_ptr< Request > &, const std::string &message)> | onResponseParseError |
Friends | |
| class | commands::SendFileCommand |
| class | commands::SendFragmentCommand |
| class | commands::SendHeaderCommand |
| class | commands::UpgradeCommand |
| class | commands::EndCommand |
| class | commands::SseCommand |
| class | SocketContext |
Additional Inherited Members | |
Public Attributes inherited from web::http::client::Request | |
| std::string | hostFieldValue |
| std::string | method = "GET" |
| std::string | url = "/" |
| int | httpMajor = 1 |
| int | httpMinor = 1 |
| std::size_t | count {0} |
Protected Member Functions inherited from web::http::client::Request | |
| Request (Request &&request) noexcept | |
| void | upgrade (const std::shared_ptr< Response > &response, const std::function< void(const std::string &)> &status) |
Protected Member Functions inherited from core::pipe::Sink | |
| Sink ()=default | |
| Sink (Sink &&) noexcept=default | |
| Sink & | operator= (Sink &&) noexcept=default |
| virtual | ~Sink () |
| bool | isStreaming () |
| void | stop () |
Protected Attributes inherited from web::http::client::Request | |
| CiStringMap< std::string > | queries |
| CiStringMap< std::string > | headers |
| CiStringMap< std::string > | cookies |
| CiStringMap< std::string > | trailer |
| std::size_t | contentLength = 0 |
| std::weak_ptr< MasterRequest > | masterRequest |
| web::http::client::SocketContext * | socketContext |
| TransferEncoding | transferEncoding = TransferEncoding::HTTP10 |
| ConnectionState | connectionState = ConnectionState::Default |
| web::http::client::MasterRequest::MasterRequest | ( | SocketContext * | socketContext, |
| const std::string & | hostFieldValue | ||
| ) |
Definition at line 308 of file Request.cpp.
References init(), and web::http::client::Request::Request().
|
explicitdelete |
|
explicitnoexcept |
Definition at line 313 of file Request.cpp.
References contentLengthSent, init(), onResponseParseError, onResponseReceived, web::http::client::Request::Request(), and requestCommands.
|
override |
Definition at line 322 of file Request.cpp.
References core::pipe::Sink::isStreaming(), web::http::client::Request::masterRequest, requestCommands, web::http::client::Request::socketContext, and core::socket::stream::SocketContext::streamEof().
|
private |
Definition at line 716 of file Request.cpp.
References onResponseReceived.
Referenced by web::http::client::SocketContext::deliverResponse().
|
private |
Definition at line 720 of file Request.cpp.
References onResponseParseError.
Referenced by web::http::client::SocketContext::deliverResponseParseError().
| bool web::http::client::MasterRequest::end | ( | const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> & | onResponseReceived, |
| const std::function< void(const std::shared_ptr< Request > &, const std::string &)> & | onResponseParseError | ||
| ) |
Definition at line 524 of file Request.cpp.
References web::http::client::commands::EndCommand::EndCommand(), web::http::client::Request::masterRequest, requestCommands, requestPrepared(), and sendHeader().
|
private |
Definition at line 656 of file Request.cpp.
Referenced by web::http::client::commands::EndCommand::execute(), and executeSendFile().
|
private |
Definition at line 567 of file Request.cpp.
References web::http::client::Request::contentLength, web::http::MimeTypes::contentType(), executeEnd(), executeSendHeader(), httputils::file_mod_http_date(), web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, core::file::FileReader::open(), core::pipe::Source::pipe(), and web::http::client::Request::set().
Referenced by web::http::client::commands::SendFileCommand::execute().
|
private |
Definition at line 696 of file Request.cpp.
References web::http::Chunked, web::http::client::Request::contentLength, contentLengthSent, core::socket::stream::SocketContext::sendToPeer(), core::socket::SocketContext::sendToPeer(), web::http::client::Request::socketContext, and web::http::client::Request::transferEncoding.
Referenced by web::http::client::commands::SendFragmentCommand::execute(), onSourceData(), and requestDelivered().
|
private |
Definition at line 664 of file Request.cpp.
References web::http::client::Request::contentLength, web::http::client::Request::cookies, web::http::client::Request::headers, web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, web::http::client::Request::method, web::http::client::Request::queries, core::socket::SocketContext::sendToPeer(), web::http::client::Request::set(), web::http::client::Request::socketContext, httputils::to_http_date(), web::http::client::Request::url, and httputils::url_encode().
Referenced by web::http::client::commands::SendHeaderCommand::execute(), executeSendFile(), and executeUpgrade().
|
private |
Definition at line 660 of file Request.cpp.
Referenced by web::http::client::commands::SseCommand::execute().
|
private |
Definition at line 610 of file Request.cpp.
References web::http::client::SocketContextUpgradeFactory::checkRefCount(), core::socket::stream::SocketContext::close(), web::http::client::Request::cookies, executeSendHeader(), core::socket::stream::SocketConnection::getConnectionName(), core::socket::stream::SocketContext::getSocketConnection(), web::http::client::Request::getSocketContext(), web::http::client::Request::headers, web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, web::http::client::SocketContextUpgradeFactorySelector::instance(), web::http::client::Request::method, web::http::SocketContextUpgradeFactory< RequestT, ResponseT >::name(), web::http::client::Request::queries, web::http::client::SocketContextUpgradeFactorySelector::select(), web::http::client::Request::set(), web::http::client::Request::socketContext, httputils::toString(), web::http::client::Request::trailer, and web::http::client::Request::url.
Referenced by web::http::client::commands::UpgradeCommand::execute().
| void web::http::client::MasterRequest::init | ( | ) |
Definition at line 332 of file Request.cpp.
References web::http::client::Request::connectionState, web::http::client::Request::contentLength, contentLengthSent, web::http::client::Request::cookies, web::http::Default, web::http::client::Request::headers, web::http::HTTP10, web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, web::http::client::Request::method, web::http::client::Request::queries, requestCommands, web::http::client::Request::trailer, web::http::client::Request::transferEncoding, and web::http::client::Request::url.
Referenced by MasterRequest(), and MasterRequest().
|
private |
Definition at line 543 of file Request.cpp.
References web::http::client::RequestCommand::execute(), web::http::client::RequestCommand::getError(), onResponseParseError, web::http::client::RequestCommand::onResponseParseError, onResponseReceived, web::http::client::RequestCommand::onResponseReceived, requestCommands, and requestDelivered().
Referenced by web::http::client::SocketContext::initiateRequest().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 741 of file Request.cpp.
References web::http::client::Request::masterRequest, web::http::client::Request::socketContext, core::pipe::Source::start(), core::pipe::Source::stop(), and core::socket::stream::SocketContext::streamToPeer().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 751 of file Request.cpp.
References executeSendFragment().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 755 of file Request.cpp.
References web::http::client::Request::masterRequest, requestDelivered(), web::http::client::Request::socketContext, and core::socket::stream::SocketContext::streamEof().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 763 of file Request.cpp.
References core::socket::stream::SocketContext::close(), web::http::client::Request::masterRequest, requestDelivered(), web::http::client::Request::socketContext, and core::socket::stream::SocketContext::streamEof().
|
deletenoexcept |
|
delete |
|
private |
Definition at line 724 of file Request.cpp.
References web::http::Chunked, web::http::client::Request::contentLength, contentLengthSent, executeSendFragment(), web::http::client::Request::masterRequest, web::http::client::SocketContext::requestDelivered(), core::socket::SocketContext::sendToPeer(), web::http::client::Request::socketContext, web::http::client::Request::trailer, and web::http::client::Request::transferEncoding.
Referenced by initiate(), onSourceEof(), and onSourceError().
| bool web::http::client::MasterRequest::requestEventSource | ( | const std::string & | url, |
| const std::function< std::size_t()> & | onServerSentEvent, | ||
| const std::function< void()> & | onOpen, | ||
| const std::function< void()> & | onError | ||
| ) |
Definition at line 435 of file Request.cpp.
References web::http::ciContains(), core::socket::stream::SocketConnection::getConnectionName(), core::socket::stream::SocketContext::getSocketConnection(), web::http::client::Request::getSocketContext(), web::http::client::Request::header(), web::http::client::Response::headers, web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, web::http::client::Request::masterRequest, requestCommands, requestPrepared(), sendHeader(), web::http::client::Request::set(), web::http::client::SocketContext::setSseEventReceiver(), core::socket::stream::SocketContext::shutdownWrite(), web::http::client::commands::SseCommand::SseCommand(), and web::http::client::Request::url.
|
private |
Definition at line 712 of file Request.cpp.
References web::http::client::SocketContext::requestPrepared(), and web::http::client::Request::socketContext.
Referenced by end(), requestEventSource(), send(), sendFile(), and upgrade().
| bool web::http::client::MasterRequest::send | ( | const char * | chunk, |
| std::size_t | chunkLen, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> & | onResponseReceived, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::string &)> & | onResponseParseError | ||
| ) |
Definition at line 349 of file Request.cpp.
References web::http::client::commands::EndCommand::EndCommand(), web::http::client::Request::masterRequest, requestCommands, requestPrepared(), sendFragment(), sendHeader(), and web::http::client::Request::set().
Referenced by send().
| bool web::http::client::MasterRequest::send | ( | const std::string & | chunk, |
| const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> & | onResponseReceived, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::string &)> & | onResponseParseError | ||
| ) |
Definition at line 377 of file Request.cpp.
References send(), and web::http::client::Request::set().
Referenced by main().
| bool web::http::client::MasterRequest::sendFile | ( | const std::string & | file, |
| const std::function< void(int errnum)> & | onStatus, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> & | onResponseReceived, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::string &)> & | onResponseParseError | ||
| ) |
Definition at line 481 of file Request.cpp.
References web::http::client::Request::masterRequest, requestCommands, requestPrepared(), and web::http::client::commands::SendFileCommand::SendFileCommand().
| MasterRequest & web::http::client::MasterRequest::sendFragment | ( | const char * | chunk, |
| std::size_t | chunkLen | ||
| ) |
Definition at line 509 of file Request.cpp.
References web::http::client::Request::contentLength, web::http::client::Request::masterRequest, requestCommands, and web::http::client::commands::SendFragmentCommand::SendFragmentCommand().
Referenced by send(), and sendFragment().
| MasterRequest & web::http::client::MasterRequest::sendFragment | ( | const std::string & | data | ) |
Definition at line 519 of file Request.cpp.
References sendFragment().
| MasterRequest & web::http::client::MasterRequest::sendHeader | ( | ) |
Definition at line 501 of file Request.cpp.
References web::http::client::Request::masterRequest, requestCommands, and web::http::client::commands::SendHeaderCommand::SendHeaderCommand().
Referenced by end(), requestEventSource(), and send().
| bool web::http::client::MasterRequest::upgrade | ( | const std::string & | url, |
| const std::string & | protocols, | ||
| const std::function< void(bool)> & | onUpgradeInitiate, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &, bool)> & | onResponseReceived, | ||
| const std::function< void(const std::shared_ptr< Request > &, const std::string &)> & | onResponseParseError | ||
| ) |
Definition at line 387 of file Request.cpp.
References web::http::client::Response::body, web::http::client::Response::cookies, web::http::client::Response::get(), core::socket::stream::SocketConnection::getConnectionName(), core::socket::stream::SocketContext::getSocketConnection(), web::http::client::Request::getSocketContext(), web::http::client::Request::header(), web::http::client::Response::headers, web::http::client::Request::httpMajor, web::http::client::Request::httpMinor, web::http::client::Response::httpVersion, web::http::client::Request::masterRequest, web::http::client::Request::method, web::http::client::Response::reason, requestCommands, requestPrepared(), web::http::client::Response::statusCode, httputils::toString(), web::http::client::Request::upgrade(), web::http::client::commands::UpgradeCommand::UpgradeCommand(), and web::http::client::Request::url.
Referenced by main().
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
Definition at line 220 of file Request.h.
Referenced by executeSendFragment(), init(), MasterRequest(), and requestDelivered().
|
private |
Definition at line 223 of file Request.h.
Referenced by deliverResponseParseError(), initiate(), and MasterRequest().
|
private |
Definition at line 222 of file Request.h.
Referenced by deliverResponse(), initiate(), and MasterRequest().
|
private |
Definition at line 218 of file Request.h.
Referenced by end(), init(), initiate(), MasterRequest(), requestEventSource(), send(), sendFile(), sendFragment(), sendHeader(), upgrade(), and ~MasterRequest().