SNode.C
|
#include <Request.h>
Public Member Functions | |
Request (web::http::client::SocketContext *socketContext, const std::string &host) | |
Request (Request &)=delete | |
Request (Request &&) noexcept | |
Request & | operator= (Request &)=delete |
Request & | operator= (Request &&) noexcept=delete |
~Request () override | |
void | setMasterRequest (const std::shared_ptr< Request > &masterRequest) |
virtual void | init () |
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) |
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=responseParseError) |
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=responseParseError) |
bool | upgrade (const std::string &url, const std::string &protocols, 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=responseParseError) |
void | upgrade (const std::shared_ptr< Response > &response, const std::function< void(const std::string &)> &status) |
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=responseParseError) |
Request & | sendHeader () |
Request & | sendFragment (const char *chunk, std::size_t chunkLen) |
Request & | 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=responseParseError) |
std::string | header (const std::string &field) |
const CiStringMap< std::string > & | getQueries () const |
const CiStringMap< std::string > & | getHeaders () const |
const CiStringMap< std::string > & | getCookies () const |
web::http::client::SocketContext * | getSocketContext () const |
![]() | |
Sink (Sink &)=delete | |
Sink & | operator= (Sink &)=delete |
Static Public Member Functions | |
static void | responseParseError (const std::shared_ptr< Request > &request, const std::string &message) |
Public Attributes | |
std::string | hostFieldValue |
std::string | method = "GET" |
std::string | url = "/" |
int | httpMajor = 1 |
int | httpMinor = 1 |
Protected Attributes | |
CiStringMap< std::string > | queries |
CiStringMap< std::string > | headers |
CiStringMap< std::string > | cookies |
CiStringMap< std::string > | trailer |
Private Member Functions | |
bool | initiate () |
bool | executeSendFile (const std::string &file, const std::function< void(int)> &onStatus) |
bool | executeUpgrade (const std::string &url, const std::string &protocols) |
bool | executeEnd () |
bool | executeSendHeader () |
bool | executeSendFragment (const char *chunk, std::size_t chunkLen) |
void | requestPrepared () |
void | requestDelivered () |
void | deliverResponse (const std::shared_ptr< Request > &request, const std::shared_ptr< Response > &response) |
void | deliverResponseParseError (const std::shared_ptr< Request > &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 |
TransferEncoding | transferEncoding = TransferEncoding::HTTP10 |
std::size_t | contentLength = 0 |
std::size_t | contentLengthSent = 0 |
ConnectionState | connectionState = ConnectionState::Default |
std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> | onResponseReceived |
std::function< void(const std::shared_ptr< Request > &request, const std::string &message)> | onResponseParseError |
std::weak_ptr< Request > | masterRequest |
web::http::client::SocketContext * | socketContext |
Friends | |
class | commands::SendFileCommand |
class | commands::SendFragmentCommand |
class | commands::SendHeaderCommand |
class | commands::UpgradeCommand |
class | commands::EndCommand |
class | SocketContext |
Additional Inherited Members | |
![]() | |
Sink ()=default | |
Sink (Sink &&) noexcept=default | |
Sink & | operator= (Sink &&) noexcept=default |
virtual | ~Sink () |
bool | isStreaming () |
void | stop () |
|
explicit |
Definition at line 53 of file Request.cpp.
|
explicitdelete |
|
explicitnoexcept |
Definition at line 59 of file Request.cpp.
References httpMajor, httpMinor, init(), and Request().
Referenced by Request().
|
override |
Definition at line 81 of file Request.cpp.
Request & web::http::client::Request::append | ( | const std::string & | field, |
const std::string & | value ) |
Definition at line 125 of file Request.cpp.
Request & web::http::client::Request::cookie | ( | const std::map< std::string, std::string > & | cookies | ) |
Definition at line 203 of file Request.cpp.
Request & web::http::client::Request::cookie | ( | const std::string & | name, |
const std::string & | value ) |
Definition at line 197 of file Request.cpp.
|
private |
Definition at line 558 of file Request.cpp.
|
private |
Definition at line 562 of file Request.cpp.
bool web::http::client::Request::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 = responseParseError ) |
Definition at line 394 of file Request.cpp.
References requestPrepared(), and sendHeader().
|
private |
Definition at line 501 of file Request.cpp.
|
private |
Definition at line 439 of file Request.cpp.
|
private |
Definition at line 537 of file Request.cpp.
|
private |
Definition at line 505 of file Request.cpp.
Referenced by executeUpgrade().
|
private |
Definition at line 481 of file Request.cpp.
References executeSendHeader().
const web::http::CiStringMap< std::string > & web::http::client::Request::getCookies | ( | ) | const |
Definition at line 628 of file Request.cpp.
const web::http::CiStringMap< std::string > & web::http::client::Request::getHeaders | ( | ) | const |
Definition at line 624 of file Request.cpp.
const web::http::CiStringMap< std::string > & web::http::client::Request::getQueries | ( | ) | const |
Definition at line 620 of file Request.cpp.
SocketContext * web::http::client::Request::getSocketContext | ( | ) | const |
Definition at line 632 of file Request.cpp.
std::string web::http::client::Request::header | ( | const std::string & | field | ) |
Definition at line 616 of file Request.cpp.
Request & web::http::client::Request::host | ( | const std::string & | hostFieldValue | ) |
Definition at line 119 of file Request.cpp.
|
virtual |
Definition at line 95 of file Request.cpp.
References httpMajor, and httpMinor.
Referenced by Request(), and requestPrepared().
|
private |
Definition at line 414 of file Request.cpp.
References requestDelivered().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 583 of file Request.cpp.
References core::pipe::Source::start(), and core::pipe::Source::stop().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 593 of file Request.cpp.
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 597 of file Request.cpp.
References requestDelivered().
|
overrideprivatevirtual |
Implements core::pipe::Sink.
Definition at line 605 of file Request.cpp.
References requestDelivered().
Request & web::http::client::Request::query | ( | const std::string & | key, |
const std::string & | value ) |
Definition at line 211 of file Request.cpp.
|
private |
Definition at line 566 of file Request.cpp.
Referenced by initiate(), onSourceEof(), and onSourceError().
|
private |
Definition at line 553 of file Request.cpp.
References init().
Referenced by end(), send(), sendFile(), and upgrade().
|
static |
Definition at line 236 of file Request.cpp.
bool web::http::client::Request::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 = responseParseError ) |
Definition at line 242 of file Request.cpp.
References requestPrepared(), and sendHeader().
bool web::http::client::Request::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 = responseParseError ) |
Definition at line 269 of file Request.cpp.
bool web::http::client::Request::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 = responseParseError ) |
Definition at line 352 of file Request.cpp.
References requestPrepared().
Request & web::http::client::Request::sendFragment | ( | const char * | chunk, |
std::size_t | chunkLen ) |
Definition at line 380 of file Request.cpp.
Request & web::http::client::Request::sendFragment | ( | const std::string & | data | ) |
Definition at line 390 of file Request.cpp.
Request & web::http::client::Request::sendHeader | ( | ) |
Definition at line 372 of file Request.cpp.
Referenced by end(), and send().
Request & web::http::client::Request::set | ( | const std::map< std::string, std::string > & | headers, |
bool | overwrite = true ) |
Definition at line 183 of file Request.cpp.
Request & web::http::client::Request::set | ( | const std::string & | field, |
const std::string & | value, | ||
bool | overwrite = true ) |
Definition at line 137 of file Request.cpp.
void web::http::client::Request::setMasterRequest | ( | const std::shared_ptr< Request > & | masterRequest | ) |
Definition at line 91 of file Request.cpp.
Request & web::http::client::Request::setTrailer | ( | const std::string & | field, |
const std::string & | value, | ||
bool | overwrite = true ) |
Definition at line 217 of file Request.cpp.
Request & web::http::client::Request::type | ( | const std::string & | type | ) |
Definition at line 191 of file Request.cpp.
void web::http::client::Request::upgrade | ( | const std::shared_ptr< Response > & | response, |
const std::function< void(const std::string &)> & | status ) |
Definition at line 299 of file Request.cpp.
bool web::http::client::Request::upgrade | ( | const std::string & | url, |
const std::string & | protocols, | ||
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 = responseParseError ) |
Definition at line 279 of file Request.cpp.
References requestPrepared().
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
protected |
|
protected |
int web::http::client::Request::httpMajor = 1 |
Definition at line 145 of file Request.h.
Referenced by init(), web::http::client::SocketContext::onDisconnected(), Request(), and web::http::client::SocketContext::requestPrepared().
int web::http::client::Request::httpMinor = 1 |
Definition at line 146 of file Request.h.
Referenced by init(), web::http::client::SocketContext::onDisconnected(), Request(), and web::http::client::SocketContext::requestPrepared().
|
private |
|
private |
|
protected |
|
private |
|
private |
|
protected |
|
private |