proxygen
|
#include <CurlClient.h>
Public Member Functions | |
CurlClient (folly::EventBase *evb, proxygen::HTTPMethod httpMethod, const proxygen::URL &url, const proxygen::URL *proxy, const proxygen::HTTPHeaders &headers, const std::string &inputFilename, bool h2c=false, unsigned short httpMajor=1, unsigned short httpMinor=1) | |
virtual | ~CurlClient ()=default |
void | initializeSsl (const std::string &caPath, const std::string &nextProtos, const std::string &certPath="", const std::string &keyPath="") |
void | sslHandshakeFollowup (proxygen::HTTPUpstreamSession *session) noexcept |
void | connectSuccess (proxygen::HTTPUpstreamSession *session) override |
void | connectError (const folly::AsyncSocketException &ex) override |
void | setTransaction (proxygen::HTTPTransaction *txn) noexceptoverride |
void | detachTransaction () noexceptoverride |
void | onHeadersComplete (std::unique_ptr< proxygen::HTTPMessage > msg) noexceptoverride |
void | onBody (std::unique_ptr< folly::IOBuf > chain) noexceptoverride |
void | onTrailers (std::unique_ptr< proxygen::HTTPHeaders > trailers) noexceptoverride |
void | onEOM () noexceptoverride |
void | onUpgrade (proxygen::UpgradeProtocol protocol) noexceptoverride |
void | onError (const proxygen::HTTPException &error) noexceptoverride |
void | onEgressPaused () noexceptoverride |
void | onEgressResumed () noexceptoverride |
void | sendRequest (proxygen::HTTPTransaction *txn) |
folly::SSLContextPtr | getSSLContext () |
const std::string & | getServerName () const |
void | setFlowControlSettings (int32_t recvWindow) |
const proxygen::HTTPMessage * | getResponse () const |
void | setLogging (bool enabled) |
Public Member Functions inherited from proxygen::HTTPConnector::Callback | |
virtual | ~Callback () |
Public Member Functions inherited from proxygen::HTTPTransactionHandler | |
virtual void | onChunkHeader (size_t) noexcept |
virtual void | onChunkComplete () noexcept |
virtual void | onPushedTransaction (HTTPTransaction *) noexcept |
virtual void | onExTransaction (HTTPTransaction *) noexcept |
virtual void | onGoaway (ErrorCode) noexcept |
virtual | ~HTTPTransactionHandler () |
Static Public Member Functions | |
static proxygen::HTTPHeaders | parseHeaders (const std::string &headersString) |
Protected Attributes | |
proxygen::HTTPTransaction * | txn_ {nullptr} |
folly::EventBase * | evb_ {nullptr} |
proxygen::HTTPMethod | httpMethod_ |
proxygen::URL | url_ |
std::unique_ptr< proxygen::URL > | proxy_ |
proxygen::HTTPMessage | request_ |
const std::string | inputFilename_ |
folly::SSLContextPtr | sslContext_ |
int32_t | recvWindow_ {0} |
bool | loggingEnabled_ {true} |
bool | h2c_ {false} |
unsigned short | httpMajor_ |
unsigned short | httpMinor_ |
std::unique_ptr< proxygen::HTTPMessage > | response_ |
Definition at line 20 of file CurlClient.h.
CurlService::CurlClient::CurlClient | ( | folly::EventBase * | evb, |
proxygen::HTTPMethod | httpMethod, | ||
const proxygen::URL & | url, | ||
const proxygen::URL * | proxy, | ||
const proxygen::HTTPHeaders & | headers, | ||
const std::string & | inputFilename, | ||
bool | h2c = false , |
||
unsigned short | httpMajor = 1 , |
||
unsigned short | httpMinor = 1 |
||
) |
Definition at line 23 of file CurlClient.cpp.
References proxygen::HTTPHeaders::add(), proxygen::HTTPHeaders::forEach(), proxygen::HTTPMessage::getHeaders(), proxygen::URL::getUrl(), proxy_, request_, and val.
|
virtualdefault |
|
overridevirtual |
Implements proxygen::HTTPConnector::Callback.
Definition at line 178 of file CurlClient.cpp.
References proxygen::ERROR, proxygen::URL::getHostAndPort(), loggingEnabled_, and url_.
|
overridevirtual |
Implements proxygen::HTTPConnector::Callback.
Definition at line 112 of file CurlClient.cpp.
References proxygen::HTTPSession::closeWhenIdle(), proxygen::URL::isSecure(), proxygen::HTTPUpstreamSession::newTransaction(), recvWindow_, sendRequest(), proxygen::HTTPSession::setFlowControl(), sslHandshakeFollowup(), and url_.
|
overridevirtualnoexcept |
Called once after a transaction successfully completes. It will be called even if a read or write error happened earlier. This is a terminal callback, which means that the HTTPTransaction object that gives this call will be invalid after this function completes.
Implements proxygen::HTTPTransactionHandler.
Definition at line 186 of file CurlClient.cpp.
|
inline |
Definition at line 72 of file CurlClient.h.
References response_.
Referenced by TEST().
const string & CurlService::CurlClient::getServerName | ( | ) | const |
Definition at line 239 of file CurlClient.cpp.
References proxygen::HTTPMessage::getHeaders(), proxygen::URL::getHost(), proxygen::HTTPHeaders::getSingleOrEmpty(), proxygen::HTTP_HEADER_HOST, request_, and url_.
Referenced by getSSLContext().
|
inline |
Definition at line 66 of file CurlClient.h.
References getServerName(), int32_t, setFlowControlSettings(), sslContext_, and string.
void CurlService::CurlClient::initializeSsl | ( | const std::string & | caPath, |
const std::string & | nextProtos, | ||
const std::string & | certPath = "" , |
||
const std::string & | keyPath = "" |
||
) |
Definition at line 69 of file CurlClient.cpp.
References h2c_, folly::ssl::SSLCommonOptions::kCipherList, and sslContext_.
|
overridevirtualnoexcept |
Can be called multiple times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().
Implements proxygen::HTTPTransactionHandler.
Definition at line 201 of file CurlClient.cpp.
References folly::IOBuf::data(), folly::IOBuf::length(), loggingEnabled_, and folly::IOBuf::next().
|
overridevirtualnoexcept |
If the remote side's receive buffer fills up, this callback will be invoked so you can attempt to stop sending to the remote side.
Implements proxygen::HTTPTransactionHandler.
Definition at line 231 of file CurlClient.cpp.
References folly::INFO, and loggingEnabled_.
|
overridevirtualnoexcept |
This callback lets you know that the remote side has resumed reading and you can now continue to send data.
Implements proxygen::HTTPTransactionHandler.
Definition at line 235 of file CurlClient.cpp.
References folly::INFO, and loggingEnabled_.
|
overridevirtualnoexcept |
Can be called once per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). After this callback is received, there will be no more normal ingress callbacks received (onEgress*() and onError() may still be invoked). The Handler should consider ingress complete after receiving this message. This Transaction is still valid, and work may still occur on it until detachTransaction is called.
Implements proxygen::HTTPTransactionHandler.
Definition at line 219 of file CurlClient.cpp.
References folly::INFO, and loggingEnabled_.
|
overridevirtualnoexcept |
Can be called at any time before detachTransaction(). This callback implies that an error has occurred. To determine if ingress or egress is affected, check the direciont on the HTTPException. If the direction is INGRESS, it MAY still be possible to send egress.
Implements proxygen::HTTPTransactionHandler.
Definition at line 227 of file CurlClient.cpp.
References proxygen::ERROR, folly::pushmi::operators::error(), and loggingEnabled_.
|
overridevirtualnoexcept |
Called at most once per transaction. This is usually the first ingress callback. It is possible to get a read error before this however. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress().
Implements proxygen::HTTPTransactionHandler.
Definition at line 189 of file CurlClient.cpp.
References loggingEnabled_, folly::gen::move, response_, and val.
|
overridevirtualnoexcept |
Can be called any number of times per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). Trailers can be received once right before the EOM of a chunked HTTP/1.1 reponse or multiple times per transaction from SPDY and HTTP/2.0 HEADERS frames.
Implements proxygen::HTTPTransactionHandler.
Definition at line 215 of file CurlClient.cpp.
References folly::INFO, and loggingEnabled_.
|
overridevirtualnoexcept |
Can be called once per transaction. If you had previously called pauseIngress(), this callback will be delayed until you call resumeIngress(). After this callback is invoked, further data will be forwarded using the onBody() callback. Once the data transfer is completed (EOF recevied in case of CONNECT), onEOM() callback will be invoked.
Implements proxygen::HTTPTransactionHandler.
Definition at line 223 of file CurlClient.cpp.
References folly::INFO, and loggingEnabled_.
|
static |
Definition at line 48 of file CurlClient.cpp.
References proxygen::HTTPHeaders::add(), folly::empty(), folly::split(), and value.
Referenced by main().
void CurlService::CurlClient::sendRequest | ( | proxygen::HTTPTransaction * | txn | ) |
Definition at line 123 of file CurlClient.cpp.
References proxygen::HTTPHeaders::add(), folly::IOBuf::append(), proxygen::HTTPMessage::dumpMessage(), proxygen::HTTPMessage::getHeaders(), proxygen::URL::getHostAndPort(), proxygen::HTTPHeaders::getNumberOfValues(), proxygen::URL::getUrl(), h2c_, proxygen::HTTP_HEADER_ACCEPT, proxygen::HTTP_HEADER_HOST, proxygen::HTTP_HEADER_USER_AGENT, httpMajor_, httpMethod_, httpMinor_, inputFilename_, proxygen::URL::isSecure(), loggingEnabled_, proxygen::URL::makeRelativeURL(), folly::gen::move, proxy_, request_, proxygen::HTTPTransaction::sendBody(), proxygen::HTTPTransaction::sendEOM(), proxygen::HTTPTransaction::sendHeaders(), proxygen::HTTPMessage::setHTTPVersion(), proxygen::HTTPMessage::setMethod(), proxygen::HTTPMessage::setSecure(), proxygen::HTTPMessage::setURL(), txn_, uint16_t, url_, and folly::IOBuf::writableData().
Referenced by connectSuccess().
void CurlService::CurlClient::setFlowControlSettings | ( | int32_t | recvWindow | ) |
Definition at line 108 of file CurlClient.cpp.
References recvWindow_.
Referenced by getSSLContext(), main(), and TEST().
|
inline |
|
overridevirtualnoexcept |
Called once per transaction. This notifies the handler of which transaction it should talk to and will receive callbacks from.
Implements proxygen::HTTPTransactionHandler.
Definition at line 183 of file CurlClient.cpp.
|
noexcept |
Definition at line 89 of file CurlClient.cpp.
References folly::AsyncSSLSocket::getSelectedNextProtocol(), and string.
Referenced by connectSuccess().
|
protected |
Definition at line 82 of file CurlClient.h.
|
protected |
Definition at line 91 of file CurlClient.h.
Referenced by initializeSsl(), and sendRequest().
|
protected |
Definition at line 92 of file CurlClient.h.
Referenced by sendRequest().
|
protected |
Definition at line 83 of file CurlClient.h.
Referenced by sendRequest().
|
protected |
Definition at line 93 of file CurlClient.h.
Referenced by sendRequest().
|
protected |
Definition at line 87 of file CurlClient.h.
Referenced by sendRequest().
|
protected |
Definition at line 90 of file CurlClient.h.
Referenced by connectError(), onBody(), onEgressPaused(), onEgressResumed(), onEOM(), onError(), onHeadersComplete(), onTrailers(), onUpgrade(), sendRequest(), and setLogging().
|
protected |
Definition at line 85 of file CurlClient.h.
Referenced by CurlClient(), and sendRequest().
|
protected |
Definition at line 89 of file CurlClient.h.
Referenced by connectSuccess(), and setFlowControlSettings().
|
protected |
Definition at line 86 of file CurlClient.h.
Referenced by CurlClient(), getServerName(), and sendRequest().
|
protected |
Definition at line 95 of file CurlClient.h.
Referenced by getResponse(), and onHeadersComplete().
|
protected |
Definition at line 88 of file CurlClient.h.
Referenced by getSSLContext(), and initializeSsl().
|
protected |
Definition at line 81 of file CurlClient.h.
Referenced by sendRequest().
|
protected |
Definition at line 84 of file CurlClient.h.
Referenced by connectError(), connectSuccess(), getServerName(), and sendRequest().