15 using namespace folly;
28 const string& inputFilename,
30 unsigned short httpMajor,
31 unsigned short httpMinor)
33 httpMethod_(httpMethod),
35 inputFilename_(inputFilename),
37 httpMajor_(httpMajor),
38 httpMinor_(httpMinor) {
39 if (proxy !=
nullptr) {
43 headers.
forEach([
this] (
const string& header,
const string&
val) {
49 vector<StringPiece> headersList;
52 for (
const auto& headerPair: headersList) {
53 vector<StringPiece> nv;
63 headers.
add(nv[0], value);
70 const string& nextProtos,
71 const string& certPath,
72 const string& keyPath) {
73 sslContext_ = std::make_shared<folly::SSLContext>();
76 if (!caPath.empty()) {
77 sslContext_->loadTrustedCertificates(caPath.c_str());
79 if (!certPath.empty() && !keyPath.empty()) {
80 sslContext_->loadCertKeyPairFromFiles(certPath.c_str(), keyPath.c_str());
82 list<string> nextProtoList;
83 folly::splitTo<string>(
',', nextProtos, std::inserter(nextProtoList,
84 nextProtoList.begin()));
85 sslContext_->setAdvertisedNextProtocols(nextProtoList);
91 session->getTransport());
93 const unsigned char* nextProto =
nullptr;
94 unsigned nextProtoLength = 0;
97 VLOG(1) <<
"Client selected next protocol " <<
98 string((
const char*)nextProto, nextProtoLength);
100 VLOG(1) <<
"Client did not select a next protocol";
134 HTTP2Codec::requestUpgrade(
request_);
152 unique_ptr<IOBuf> buf;
164 while (inputFile.good()) {
165 buf = IOBuf::createCombined(kReadSize);
167 buf->
append(inputFile.gcount());
194 cout <<
response_->getStatusCode() <<
" " 195 <<
response_->getStatusMessage() << endl;
196 response_->getHeaders().forEach([&](
const string& header,
const string&
val) {
197 cout << header <<
": " << val << endl;
206 const IOBuf* p = chain.get();
208 cout.write((
const char*)p->
data(), p->
length());
211 }
while (p != chain.get());
static proxygen::HTTPHeaders parseHeaders(const std::string &headersString)
folly::SSLContextPtr sslContext_
void onEgressResumed() noexceptoverride
const std::string & getHost() const noexcept
HTTPTransaction * newTransaction(HTTPTransaction::Handler *handler) override
std::string makeRelativeURL() const noexcept
const std::string inputFilename_
void onError(const proxygen::HTTPException &error) noexceptoverride
void detachTransaction() noexceptoverride
void setFlowControlSettings(int32_t recvWindow)
unsigned short httpMajor_
std::unique_ptr< proxygen::HTTPMessage > response_
void onEgressPaused() noexceptoverride
proxygen::HTTPMethod httpMethod_
constexpr detail::Map< Move > move
const uint8_t * data() const
const std::string & getUrl() const noexcept
void connectSuccess(proxygen::HTTPUpstreamSession *session) override
—— Concurrent Priority Queue Implementation ——
void onUpgrade(proxygen::UpgradeProtocol protocol) noexceptoverride
void onTrailers(std::unique_ptr< proxygen::HTTPHeaders > trailers) noexceptoverride
requires E e noexcept(noexcept(s.error(std::move(e))))
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
std::string getHostAndPort() const noexcept
void sslHandshakeFollowup(proxygen::HTTPUpstreamSession *session) noexcept
void connectError(const folly::AsyncSocketException &ex) override
void setSecure(bool secure)
constexpr auto empty(C const &c) -> decltype(c.empty())
void setTransaction(proxygen::HTTPTransaction *txn) noexceptoverride
void setFlowControl(size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize) override
void onBody(std::unique_ptr< folly::IOBuf > chain) noexceptoverride
std::size_t length() const
static constexpr auto kCipherList
proxygen::HTTPTransaction * txn_
virtual void sendBody(std::unique_ptr< folly::IOBuf > body)
virtual void sendHeaders(const HTTPMessage &headers)
static const char *const value
HTTPHeaders & getHeaders()
DECLARE_int32(recv_window)
void setMethod(HTTPMethod method)
void onEOM() noexceptoverride
bool isSecure() const noexcept
const std::string & getServerName() const
void setHTTPVersion(uint8_t major, uint8_t minor)
void initializeSsl(const std::string &caPath, const std::string &nextProtos, const std::string &certPath="", const std::string &keyPath="")
void closeWhenIdle() override
std::unique_ptr< proxygen::URL > proxy_
void onHeadersComplete(std::unique_ptr< proxygen::HTTPMessage > msg) noexceptoverride
void sendRequest(proxygen::HTTPTransaction *txn)
void dumpMessage(int verbosity) const
proxygen::HTTPMessage request_
void append(std::size_t amount)
unsigned short httpMinor_
virtual void getSelectedNextProtocol(const unsigned char **protoName, unsigned *protoLen) const