30 using namespace folly;
35 using std::unique_ptr;
40 virtual std::unique_ptr<HTTPUpstreamSession::PriorityAdapter>
55 if (priorityMap_.empty()) {
58 auto it = priorityMap_.find(level);
59 if (it == priorityMap_.end()) {
76 std::unique_ptr<HTTPUpstreamSession::PriorityAdapter>
79 std::unique_ptr<TestPriorityAdapter>
a =
80 std::make_unique<TestPriorityAdapter>();
84 std::get<2>(a->
hiPri_) = hiPriWeight_;
89 std::get<2>(a->
loPri_) = loPriWeight_;
101 bool expect100 =
false) {
110 std::unique_ptr<folly::IOBuf>
116 egressCodec->generateSettings(respBufQ);
121 egressCodec->generateHeader(respBufQ,
id, msg);
124 egressCodec->generateHeader(respBufQ,
id, resp);
127 egressCodec->generateBody(respBufQ,
id,
std::move(buf),
128 HTTPCodec::NoPadding,
true );
130 return respBufQ.move();
144 std::chrono::milliseconds(
147 std::chrono::milliseconds(500))),
148 flowControl_(flowControl) {}
151 pauseWrites_ =
false;
152 for (
auto cb: cbs_) {
160 std::shared_ptr<IOBuf> iob,
163 cbs_.push_back(callback);
166 auto mybuf = iob->clone();
169 handleWrite(callback);
178 eventBase_.runInLoop([&] {
188 commonSetUp(makeClientCodec<typename C::Codec>(
C::version));
192 HTTPSession::setDefaultReadBufferLimit(65536);
193 HTTPSession::setDefaultWriteBufferLimit(65536);
197 .WillRepeatedly(SaveArg<0>(&readCallback_));
199 .WillRepeatedly(
Return(readCallback_));
201 .WillRepeatedly(ReturnPointee(&eventBasePtr_));
203 .WillRepeatedly(ReturnPointee(&transportGood_));
205 .WillRepeatedly(
Assign(&transportGood_,
false));
209 .WillRepeatedly(SaveArg<0>(&replaySafetyCallback_));
211 .WillRepeatedly(SaveArg<0>(&eventBasePtr_));
213 for (
auto& param: flowControl_) {
219 transactionTimeouts_.get(),
221 localAddr_, peerAddr_,
223 mockTransportInfo_,
this);
226 httpSession_->setMaxConcurrentOutgoingStreams(10);
227 httpSession_->setEgressSettings({{SettingsId::ENABLE_EX_HEADERS, 1}});
228 httpSession_->startNow();
230 ASSERT_EQ(this->sessionDestroyed_,
false);
234 return ::makeServerCodec<typename C::Codec>(
C::version);
238 if (!serverCodec || serverCodec->getProtocol() != CodecProtocol::HTTP_2) {
242 auto clientCodec = makeClientCodec<HTTP2Codec>(2);
244 clientCodec->getEgressSettings()->setSetting(
245 SettingsId::ENABLE_EX_HEADERS, 1);
246 clientCodec->generateConnectionPreface(c2s);
247 clientCodec->generateSettings(c2s);
250 serverCodec->getEgressSettings()->setSetting(
251 SettingsId::ENABLE_EX_HEADERS, 1);
253 auto setup = c2s.move();
254 serverCodec->onIngress(*setup);
259 while (!writes_.empty() && consumed > 0) {
260 consumed = serverCodec.
onIngress(*writes_.front());
261 writes_.split(consumed);
267 readAndLoop((
const uint8_t *)input.data(), input.length());
276 CHECK_NOTNULL(readCallback_);
280 readCallback_->getReadBuffer(&buf, &bufSize);
283 CHECK_GT(bufSize, 0);
284 bufSize =
std::min(bufSize, length);
285 memcpy(buf, input, bufSize);
286 readCallback_->readDataAvailable(bufSize);
287 eventBasePtr_->loop();
293 void testBasicRequest();
294 void testBasicRequestHttp10(
bool keepalive);
300 transactionsFull_ =
true;
303 transactionsFull_ =
false;
308 for (
auto& cb : cbs_) {
314 bool expectStartPaused =
false) {
316 auto handler = std::make_unique<StrictMock<MockHTTPHandler>>();
318 if (expectStartPaused) {
321 auto txn = httpSession_->newTransaction(
handler.get());
327 bool expectStartPaused =
false) {
329 auto handler = std::make_unique<NiceMock<MockHTTPHandler>>();
331 if (expectStartPaused) {
334 auto txn = httpSession_->newTransaction(
handler.get());
339 void testSimpleUpgrade(
const std::string& upgradeReqHeader,
345 httpSession_->setByteEventTracker(
346 std::unique_ptr<ByteEventTracker>(byteEventTracker));
348 .WillRepeatedly(
Return(0));
350 .WillRepeatedly(
Return(0));
353 (std::shared_ptr<ByteEventTracker>
self,
355 return self->ByteEventTracker::processByteEvents(
360 return byteEventTracker;
364 bool sessionCreated_{
false};
365 bool sessionDestroyed_{
false};
367 bool transactionsFull_{
false};
368 bool transportGood_{
true};
382 std::vector<folly::AsyncTransportWrapper::WriteCallback*>
cbs_;
383 bool failWrites_{
false};
384 bool pauseWrites_{
false};
385 bool writeInLoop_{
false};
399 std::chrono::milliseconds(500));
408 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
414 push.
setURL(
"https://www.foo.com/");
428 std::unique_ptr<folly::IOBuf> input = output.
move();
435 auto handler = openTransaction();
442 .WillOnce(
Invoke([&] (std::shared_ptr<HTTPMessage> msg) {
443 EXPECT_EQ(httpSession_->getNumIncomingStreams(), 1);
454 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
460 handler->expectDetachTransaction();
465 EXPECT_EQ(httpSession_->getNumIncomingStreams(), 0);
466 httpSession_->destroy();
474 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
478 std::unique_ptr<folly::IOBuf> goawayFrame = respBuf.move();
483 auto handler = openTransaction();
489 folly::to<std::string>(
"StreamUnacknowledged on transaction id: ",
493 handler->expectDetachTransaction([
this] {
496 EXPECT_EQ(httpSession_->newTransaction(&handler2),
nullptr);
503 readAndLoop(goawayFrame->
data(), goawayFrame->
length());
513 SPDYCodec egressCodec(TransportDirection::DOWNSTREAM,
516 egressCodec.
generateGoaway(respBuf, 0, ErrorCode::PROTOCOL_ERROR);
517 std::unique_ptr<folly::IOBuf> goawayFrame = respBuf.move();
522 auto handler = openTransaction();
528 folly::to<std::string>(
"StreamUnacknowledged on transaction id: ",
530 " with codec error: PROTOCOL_ERROR"),
533 handler->expectDetachTransaction([
this] {
536 EXPECT_EQ(httpSession_->newTransaction(&handler2),
nullptr);
543 readAndLoop(goawayFrame->
data(), goawayFrame->
length());
550 auto handler = openTransaction();
553 handler->txn_->sendHeaders(req);
560 eventBase_.loopOnce();
564 handler->expectDetachTransaction();
568 this->eventBase_.loop();
569 EXPECT_EQ(this->sessionDestroyed_,
true);
574 auto handler1 = openTransaction();
575 auto handler2 = openTransaction();
578 handler1->txn_->onIngressWindowUpdate(80000);
579 handler2->txn_->onIngressWindowUpdate(80000);
582 handler1->txn_->sendHeaders(req);
583 handler2->txn_->sendHeaders(req);
586 handler1->expectEgressPaused();
587 handler2->expectEgressPaused();
590 handler1->txn_->sendBody(
makeBuf(70000));
591 handler2->txn_->sendBody(
makeBuf(70000));
592 eventBase_.loopOnce();
595 handler1->expectEgressResumed([&] {
596 handler1->txn_->sendBody(
makeBuf(70000));
599 handler2->expectEgressResumed();
602 handler1->expectEgressPaused();
603 handler2->expectEgressPaused();
607 handler1->expectEgressResumed([&] { handler1->txn_->sendEOM(); });
608 handler2->expectEgressResumed([&] { handler2->txn_->sendEOM(); });
610 this->eventBase_.loop();
613 handler1->expectError();
614 handler1->expectDetachTransaction();
615 handler2->expectError();
616 handler2->expectDetachTransaction();
618 httpSession_->dropConnection();
619 EXPECT_EQ(this->sessionDestroyed_,
true);
625 auto priGroupID = httpSession_->sendPriority({0,
false, 7});
626 auto handler1 = openTransaction();
627 auto handler2 = openTransaction();
632 handler1->sendRequest(req);
633 handler2->sendRequest(req);
635 auto id = handler1->txn_->getID();
636 auto id2 = handler2->txn_->getID();
639 EXPECT_EQ(std::get<0>(handler1->txn_->getPrioritySummary()), 1);
640 EXPECT_EQ(handler1->txn_->getPriorityFallback(),
false);
643 handler1->txn_->updateAndSendPriority(
645 handler2->txn_->updateAndSendPriority(
654 serverCodec->setCallback(&callbacks);
659 std::shared_ptr<HTTPMessage> msg) {
665 std::shared_ptr<HTTPMessage> msg) {
675 EXPECT_EQ(handler1->txn_->getPriorityFallback(),
false);
676 EXPECT_EQ(handler2->txn_->getPriorityFallback(),
false);
678 EXPECT_EQ(std::get<1>(handler1->txn_->getPrioritySummary()), 2);
680 EXPECT_EQ(std::get<1>(handler2->txn_->getPrioritySummary()), 2);
683 parseOutput(*serverCodec);
686 handler1->expectError();
687 handler1->expectDetachTransaction();
688 handler2->expectError();
689 handler2->expectDetachTransaction();
690 httpSession_->dropConnection();
698 serverCodec->generateSettings(buf);
699 auto settingsFrame = buf.move();
700 settingsFrame->coalesce();
705 serverCodec->setCallback(&callbacks);
709 readAndLoop(settingsFrame.get());
710 parseOutput(*serverCodec);
711 httpSession_->dropConnection();
719 serverCodec->generateSettings(settingsBuf);
720 auto settingsFrame = settingsBuf.move();
723 serverCodec->generateSettingsAck(settingsAckBuf);
724 auto settingsAckFrame = settingsAckBuf.move();
727 httpSession_->setInfoCallback(&infoCb);
738 readAndLoop(settingsFrame.get());
739 readAndLoop(settingsAckFrame.get());
741 httpSession_->destroy();
747 EXPECT_CALL(mockController, getHeaderIndexingStrategy())
749 Return(&testH2IndexingStrat)
752 httpSession_->setController(&mockController);
754 auto handler = openTransaction();
755 handler->expectDetachTransaction();
758 &
handler->txn_->getTransport().getCodec());
765 httpSession_->destroy();
782 enableExHeader(serverCodec.get());
783 serverCodec->generateSettings(queue);
786 serverCodec->generateHeader(queue, cStreamId,
getResponse(200, 0),
789 serverCodec->generateExHeader(queue, 2,
getGetRequest(
"/messaging"),
792 serverCodec->generateEOM(queue, 1);
794 auto cHandler = openTransaction();
799 cHandler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
806 pubHandler.txn_ = pubTxn;
808 pubHandler.expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
811 pubHandler.expectEOM([&] () {
812 pubHandler.txn_->sendAbort();
814 pubHandler.expectDetachTransaction();
816 cHandler->expectEOM();
817 cHandler->expectDetachTransaction();
819 auto buf = queue.move();
821 readAndLoop(buf.get());
823 httpSession_->destroy();
831 enableExHeader(serverCodec.get());
832 serverCodec->generateSettings(queue);
835 serverCodec->generateHeader(queue, cStreamId,
getResponse(200, 0),
838 serverCodec->generateExHeader(queue, 2,
getGetRequest(
"/messaging"),
841 serverCodec->generateEOM(queue, 1);
843 auto cHandler = openTransaction();
847 cHandler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
851 cHandler->expectEOM();
852 cHandler->expectDetachTransaction();
854 auto buf = queue.move();
856 readAndLoop(buf.get());
858 httpSession_->destroy();
865 auto codec = std::make_unique<NiceMock<MockHTTPCodec>>();
866 codecPtr_ =
codec.get();
868 .WillRepeatedly(
Return(
true));
870 .WillRepeatedly(
Return(TransportDirection::UPSTREAM));
872 .WillRepeatedly(
Return(CodecProtocol::HTTP_2));
874 .WillRepeatedly(SaveArg<0>(&codecCb_));
876 .WillRepeatedly(
Invoke([&] {
877 auto ret = nextOutgoingTxn_;
878 nextOutgoingTxn_ += 2;
885 HTTPSession::setDefaultReadBufferLimit(65536);
886 HTTPSession::setDefaultWriteBufferLimit(65536);
892 .WillRepeatedly(SaveArg<0>(&readCallback_));
894 .WillRepeatedly(
Return(readCallback_));
896 .WillRepeatedly(
Return(&eventBase_));
898 .WillRepeatedly(ReturnPointee(&transportGood_));
900 .WillRepeatedly(
Assign(&transportGood_,
false));
903 transactionTimeouts_.get(),
905 localAddr_, peerAddr_,
912 ASSERT_EQ(this->sessionDestroyed_,
false);
938 for (
size_t i = 0;
i < maxLevel;
i++) {
939 dependencies.push_back(deps[
i]);
943 httpSession_->startNow();
947 handler.expectTransaction();
948 auto txn = httpSession_->newTransaction(&handler);
953 return dependencies[priority];
955 txn->updateAndSendPriority(0);
957 handler.expectError();
958 handler.expectDetachTransaction();
959 httpSession_->dropConnection();
968 builder_ = std::make_shared<TestPriorityMapBuilder>();
975 std::array<HTTPCodec::StreamID, 3> deps = { {11, 13, 15} };
982 for (
size_t i = 0;
i < maxLevel;
i++) {
983 dependencies.push_back(deps[
i]);
987 httpSession_->startNow();
993 *httpSession_->getHTTPPriority(builder_->hiPriLevel_);
994 EXPECT_EQ(std::get<2>(hiPri), builder_->hiPriWeight_);
996 *httpSession_->getHTTPPriority(builder_->loPriLevel_);
997 EXPECT_EQ(std::get<2>(loPri), builder_->loPriWeight_);
999 for (
size_t level = 0; level < 256; ++level) {
1000 if (level == builder_->hiPriLevel_) {
1008 handler.expectTransaction();
1009 auto txn = httpSession_->newTransaction(&handler);
1011 txn->updateAndSendPriority(0);
1013 handler.expectError();
1014 handler.expectDetachTransaction();
1015 httpSession_->dropConnection();
1022 this->readCallback_->readEOF();
1023 this->eventBase_.loop();
1024 EXPECT_EQ(this->sessionDestroyed_,
true);
1027 template <
class CodecPair>
1031 auto handler = openTransaction();
1032 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1038 handler->expectDetachTransaction();
1041 readAndLoop(
"HTTP/1.1 200 OK\r\n" 1042 "Transfer-Encoding: chunked\r\n\r\n" 1045 CHECK(httpSession_->supportsMoreTransactions());
1046 CHECK_EQ(httpSession_->getNumOutgoingStreams(), 0);
1051 httpSession_->destroy();
1057 httpSession_->destroy();
1064 httpSession_->destroy();
1068 auto byteEventTracker = setMockByteEventTracker();
1070 EXPECT_CALL(*byteEventTracker, addFirstHeaderByteEvent(
_,
_))
1078 auto handler = openTransaction();
1079 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1085 handler->expectDetachTransaction();
1088 readAndLoop(
"HTTP/1.1 200 OK\r\n" 1089 "Transfer-Encoding: chunked\r\n\r\n" 1092 CHECK(httpSession_->supportsMoreTransactions());
1093 CHECK_EQ(httpSession_->getNumOutgoingStreams(), 0);
1094 handler->txn_->decrementPendingByteEvents();
1095 httpSession_->destroy();
1098 template <
class CodecPair>
1108 auto handler = openTransaction();
1109 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1111 EXPECT_EQ(keepalive ?
"keep-alive" :
"close",
1116 handler->expectDetachTransaction();
1120 readAndLoop(
"HTTP/1.0 200 OK\r\n" 1121 "Connection: keep-alive\r\n" 1122 "Content-length: 7\r\n\r\n" 1125 readAndLoop(
"HTTP/1.0 200 OK\r\n" 1126 "Connection: close\r\n" 1127 "Content-length: 7\r\n\r\n" 1133 testBasicRequestHttp10(
true);
1134 testBasicRequestHttp10(
false);
1140 auto handler = openTransaction();
1141 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1148 handler->expectDetachTransaction();
1151 readAndLoop(
"HTTP/1.1 200 OK\r\n" 1152 "Transfer-Encoding: chunked\r\n\r\n" 1154 "X-Trailer1: foo\r\n" 1157 CHECK(httpSession_->supportsMoreTransactions());
1158 CHECK_EQ(httpSession_->getNumOutgoingStreams(), 0);
1159 httpSession_->destroy();
1166 egressCodec->generateSettings(output);
1171 egressCodec->generateHeader(output, 1, resp);
1173 egressCodec->generateBody(
1174 output, 1,
std::move(buf), HTTPCodec::NoPadding,
false );
1176 trailers.
set(
"trailer2",
"value2");
1177 egressCodec->generateTrailers(output, 1, trailers);
1179 std::unique_ptr<folly::IOBuf> input = output.
move();
1182 auto handler = openTransaction();
1184 handler->expectHeaders([&](std::shared_ptr<HTTPMessage> msg) {
1186 EXPECT_EQ(msg->getHeaders().getSingleOrEmpty(
"header1"),
"value1");
1189 handler->expectTrailers([&](std::shared_ptr<HTTPHeaders> trailers) {
1190 EXPECT_EQ(trailers->getSingleOrEmpty(
"trailer2"),
"value2");
1193 handler->expectDetachTransaction();
1198 httpSession_->destroy();
1205 egressCodec->generateSettings(output);
1210 egressCodec->generateHeader(output, 1, resp);
1212 egressCodec->generateBody(
1213 output, 1,
std::move(buf), HTTPCodec::NoPadding,
false );
1215 egressCodec->generateHeader(output, 1, resp);
1217 std::unique_ptr<folly::IOBuf> input = output.
move();
1220 auto handler = openTransaction();
1222 handler->expectHeaders([&](std::shared_ptr<HTTPMessage> msg) {
1224 EXPECT_EQ(msg->getHeaders().getSingleOrEmpty(
"header1"),
"value1");
1231 "Invalid ingress state transition, state=RegularBodyReceived, " 1232 "event=onHeaders, streamID=1",
1235 handler->expectDetachTransaction();
1240 httpSession_->destroy();
1246 auto handler = openTransaction();
1247 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1254 handler->expectDetachTransaction();
1257 readAndLoop(
"HTTP/1.1 200 OK\r\n" 1258 "Transfer-Encoding: chunked\r\n\r\n" 1266 httpSession_->destroy();
1274 pauseWrites_ =
true;
1278 auto handler = openTransaction();
1279 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1288 HTTPException::Direction::INGRESS_AND_EGRESS);
1291 folly::to<std::string>(
"WriteTimeout on transaction id: ",
1295 handler->expectDetachTransaction();
1297 handler->txn_->sendHeaders(req);
1299 readAndLoop(
"HTTP/1.1 200 OK\r\n" 1300 "Transfer-Encoding: chunked\r\n\r\n" 1307 auto handler = openTransaction();
1308 handler->expectDetachTransaction();
1311 handler->txn_->setIdleTimeout(std::chrono::milliseconds(747));
1314 EXPECT_EQ(transactionTimeouts_->count(), 1);
1321 httpSession_->setController(&controller);
1323 &eventBase_, std::chrono::milliseconds(50));
1324 cm->addConnection(httpSession_,
true);
1336 auto handler = openTransaction();
1337 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1342 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1348 handler->expectDetachTransaction();
1351 readAndLoop(
"HTTP/1.1 100 Continue\r\n\r\n" 1352 "HTTP/1.1 200 OK\r\n" 1353 "Transfer-Encoding: chunked\r\n\r\n" 1358 httpSession_->destroy();
1369 auto handler = openTransaction();
1370 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1376 handler->expectDetachTransaction();
1379 readAndLoop(
"HTTP/1.1 417 Expectation Failed\r\n" 1380 "Content-Length: 0\r\n\r\n");
1385 httpSession_->destroy();
1396 auto handler = openTransaction();
1397 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1403 .WillOnce(ExpectString(
"Test Body\r\n"));
1405 handler->expectDetachTransaction();
1409 readAndLoop(
"HTTP/1.1 101 Switching Protocols\r\n" 1410 "Upgrade: http/2.0\r\n\r\n" 1412 readCallback_->readEOF();
1415 CHECK_EQ(httpSession_->getNumOutgoingStreams(), 0);
1416 httpSession_->destroy();
1421 template <
class CodecPair>
1427 auto handler = openTransaction();
1430 httpSession_->setController(&controller);
1431 EXPECT_CALL(controller, onSessionCodecChange(httpSession_));
1433 EXPECT_EQ(httpSession_->getMaxConcurrentOutgoingStreams(), 1);
1436 if (respCodecVersion == CodecProtocol::HTTP_2) {
1437 EXPECT_CALL(controller, getHeaderIndexingStrategy())
1439 Return(&testH2IndexingStrat)
1443 handler->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1448 handler->expectDetachTransaction();
1452 txn->sendHeaders(req);
1454 eventBase_.loopOnce();
1456 readAndLoop(folly::to<string>(
"HTTP/1.1 101 Switching Protocols\r\n" 1457 "Upgrade: ", upgradeRespHeader,
"\r\n" 1460 if (respCodecVersion == CodecProtocol::HTTP_2) {
1462 &txn->getTransport().getCodec());
1467 readAndLoop(getResponseBuf(respCodecVersion, txn->getID(), 200, 100).
get());
1469 EXPECT_EQ(httpSession_->getMaxConcurrentOutgoingStreams(), 10);
1470 httpSession_->destroy();
1474 testSimpleUpgrade(
"h2c",
"h2c", CodecProtocol::HTTP_2);
1479 testSimpleUpgrade(
"blarf, h2c",
"h2c", CodecProtocol::HTTP_2);
1484 testSimpleUpgrade(
"blarf, \th2c\t, xyz",
"h2c",
1485 CodecProtocol::HTTP_2);
1490 testSimpleUpgrade(
",,,, ,,\t~^%$(*&@(@$^^*(,h2c",
"h2c",
1491 CodecProtocol::HTTP_2);
1496 auto handler = openTransaction();
1499 handler->expectDetachTransaction();
1503 readAndLoop(folly::to<string>(
"HTTP/1.1 101 Switching Protocols\r\n" 1504 "Upgrade: spdy/3\r\n" 1512 auto handler = openTransaction();
1515 handler->expectDetachTransaction();
1518 readAndLoop(folly::to<string>(
"HTTP/1.1 101 Switching Protocols\r\n" 1526 auto handler = openTransaction();
1529 handler->expectDetachTransaction();
1533 readAndLoop(folly::to<string>(
"HTTP/1.1 101 Switching Protocols\r\n" 1534 "Upgrade: blarf\r\n" 1542 auto handler = openTransaction();
1544 handler->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1547 handler->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1552 handler->expectDetachTransaction();
1555 HTTPMessage req = getUpgradePostRequest(100,
"h2c",
true );
1556 txn->sendHeaders(req);
1561 readAndLoop(folly::to<string>(
"HTTP/1.1 100 Continue\r\n" 1563 "HTTP/1.1 101 Switching Protocols\r\n" 1567 getResponseBuf(CodecProtocol::HTTP_2, txn->getID(), 200, 100).
get());
1568 httpSession_->destroy();
1573 auto handler = openTransaction();
1575 handler->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1578 handler->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1583 handler->expectDetachTransaction();
1586 HTTPMessage req = getUpgradePostRequest(100,
"h2c");
1587 txn->sendHeaders(req);
1592 readAndLoop(folly::to<string>(
"HTTP/1.1 101 Switching Protocols\r\n" 1595 readAndLoop(getResponseBuf(CodecProtocol::HTTP_2,
1596 txn->getID(), 200, 100,
true).
get());
1597 httpSession_->destroy();
1602 auto handler1 = openTransaction();
1604 handler1->expectHeaders([] (std::shared_ptr<HTTPMessage> msg) {
1607 handler1->expectBody();
1608 handler1->expectEOM();
1609 handler1->expectDetachTransaction();
1611 auto txn = handler1->txn_;
1613 txn->sendHeaders(req);
1615 readAndLoop(
"HTTP/1.1 200 Ok\r\n" 1616 "Content-Length: 10\r\n" 1621 auto handler2 = openTransaction();
1623 txn = handler2->txn_;
1624 txn->sendHeaders(req);
1627 handler2->expectHeaders();
1628 handler2->expectEOM();
1629 handler2->expectDetachTransaction();
1630 readAndLoop(
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
1631 httpSession_->destroy();
1643 testSimpleUpgrade(
"h2c",
"h2c", CodecProtocol::HTTP_2);
1645 HTTP2Codec serverCodec(TransportDirection::DOWNSTREAM);
1650 if (flowControl_[0] > 0) {
1651 for (
const auto& setting: settings) {
1652 if (setting.id == SettingsId::INITIAL_WINDOW_SIZE) {
1653 EXPECT_EQ(flowControl_[0], setting.value);
1658 EXPECT_CALL(callbacks, onWindowUpdate(0, flowControl_[2] -
1660 size_t initWindow = flowControl_[0] > 0 ?
1662 EXPECT_CALL(callbacks, onWindowUpdate(1, flowControl_[1] - initWindow));
1663 parseOutput(serverCodec);
1669 std::shared_ptr<IOBuf>,
1671 if (!timesCalled_++) {
1674 cbs_.push_back(callback);
1681 for (
auto& cb : cbs_) {
1682 cb->writeErr(0, ex);
1687 std::vector<folly::AsyncTransportWrapper::WriteCallback*>
cbs_;
1697 auto handler1 = openNiceTransaction();
1698 handler1->txn_->sendHeaders(req);
1699 Mock::VerifyAndClearExpectations(handler1.get());
1701 handler1->expectEgressPaused();
1703 handler1->txn_->sendBody(
makeBuf(httpSession_->getWriteBufferLimit()));
1705 Mock::VerifyAndClearExpectations(handler1.get());
1707 auto handler2 = openNiceTransaction(
true );
1709 Mock::VerifyAndClearExpectations(handler2.get());
1711 httpSession_->dropConnection();
1723 auto handler1 = openNiceTransaction();
1724 auto handler2 = openNiceTransaction();
1725 auto handler3 = openNiceTransaction();
1726 handler2->expectEgressPaused([
this] {
1728 httpSession_->dropConnection();
1730 handler2->txn_->sendHeaders(req);
1733 handler2->txn_->onIngressWindowUpdate(100);
1734 handler2->txn_->sendBody(
makeBuf(httpSession_->getWriteBufferLimit() + 1));
1741 auto codec = std::make_unique<NiceMock<MockHTTPCodec>>();
1742 codecPtr_ =
codec.get();
1744 .WillRepeatedly(
Return(
true));
1746 .WillRepeatedly(
Return(TransportDirection::UPSTREAM));
1748 .WillRepeatedly(SaveArg<0>(&codecCb_));
1750 .WillRepeatedly(ReturnPointee(&reusable_));
1752 .WillRepeatedly(ReturnPointee(&reusable_));
1754 .WillRepeatedly(
Return(65536));
1756 .WillRepeatedly(
Return(CodecProtocol::SPDY_3_1));
1761 std::shared_ptr<folly::IOBuf>) {
1764 writeBuf.
append(
"GOAWAY", 6);
1770 .WillRepeatedly(
Invoke([&] {
1771 auto ret = nextOutgoingTxn_;
1772 nextOutgoingTxn_ += 2;
1785 auto handler = std::make_unique<StrictMock<MockHTTPHandler>>();
1787 auto txn = httpSession_->newTransaction(
handler.get());
1794 bool reusable_{
true};
1799 httpSession_->setEgressSettings({{SettingsId::ENABLE_PUSH, 1}});
1806 push.
setURL(
"https://www.foo.com/");
1807 egressCodec->generateSettings(output);
1809 egressCodec->generatePushPromise(output, 2, push, 1);
1815 egressCodec->generateHeader(output, 2, resp);
1817 egressCodec->generateBody(output, 2,
std::move(buf), HTTPCodec::NoPadding,
1822 egressCodec->generateHeader(output, 1, resp);
1824 egressCodec->generateBody(output, 1,
std::move(buf), HTTPCodec::NoPadding,
1827 std::unique_ptr<folly::IOBuf> input = output.
move();
1834 auto handler = openTransaction();
1840 pushHandler.
expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1841 EXPECT_EQ(httpSession_->getNumIncomingStreams(), 1);
1848 pushHandler.
expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1850 EXPECT_EQ(msg->getHeaders().getSingleOrEmpty(
"ohai"),
"push");
1856 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1859 EXPECT_EQ(msg->getHeaders().getSingleOrEmpty(
"ohai"),
"orig");
1863 handler->expectDetachTransaction();
1868 EXPECT_EQ(httpSession_->getNumIncomingStreams(), 0);
1869 httpSession_->destroy();
1881 ON_CALL(*codecPtr_, generateRstStream(
_,
_,
_))
1882 .WillByDefault(
Return(1));
1905 auto handler = openTransaction();
1915 HTTPException ex(HTTPException::Direction::INGRESS_AND_EGRESS,
"foo");
1918 codecCb_->onError(1, ex,
true);
1921 handler->expectDetachTransaction();
1922 httpSession_->dropConnection();
1931 codecCb_->onSettings({{SettingsId::MAX_CONCURRENT_STREAMS, 0}});
1933 httpSession_->dropConnection();
1944 httpSession_->newTransaction(&handler1);
1945 httpSession_->newTransaction(&handler2);
1947 codecCb_->onSettings({{SettingsId::MAX_CONCURRENT_STREAMS, 1}});
1949 codecCb_->onSettings({{SettingsId::MAX_CONCURRENT_STREAMS, 100}});
1951 httpSession_->dropConnection();
1960 auto handler = openTransaction();
1962 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
1967 handler->expectDetachTransaction();
1973 codecCb_->onGoaway(1, ErrorCode::NO_ERROR);
1981 codecCb_->onMessageBegin(1, resp.get());
1982 codecCb_->onHeadersComplete(1,
std::move(resp));
1983 codecCb_->onMessageComplete(1,
false);
1992 const unsigned numTxns = 10;
1997 for (
unsigned i = 0;
i < numTxns; ++
i) {
1999 handler[
i].
expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2003 httpSession_->newTransaction(&handler[
i]);
2010 codecCb_->onMessageBegin(handler[i].txn_->getID(), resp.get());
2011 codecCb_->onHeadersComplete(handler[i].txn_->getID(),
std::move(resp));
2014 codecCb_->onGoaway(numTxns * 2 + 1, ErrorCode::NO_ERROR);
2015 for (
unsigned i = 0;
i < numTxns; ++
i) {
2018 codecCb_->onMessageComplete(
i*2 + 1,
false);
2040 handler.
expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2044 httpSession_->newTransaction(&handler);
2045 httpSession_->drain();
2052 codecCb_->onMessageBegin(handler.
txn_->
getID(), resp.get());
2055 codecCb_->onGoaway(1, ErrorCode::NO_ERROR);
2058 codecCb_->onMessageComplete(1,
false);
2061 auto buf = writes_.move();
2068 EXPECT_CALL(*codecPtr_, supportsStreamFlowControl())
2069 .WillRepeatedly(
Return(
true));
2071 auto handler = openTransaction();
2074 httpSession_->drain();
2078 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2086 handler->expectDetachTransaction();
2090 uint32_t toSend = sendWindow * 1.55;
2098 outstanding -= delta;
2103 eventBase_.tryRunAfterDelay(
2108 codecCb_->onMessageComplete(
streamID,
false);
2117 codecCb_->onGoaway(
streamID, ErrorCode::NO_ERROR);
2119 codecCb_->onMessageBegin(
streamID, resp.get());
2123 while (sendWindow - outstanding > 0 && toSend > 0) {
2127 len =
std::min(len, sendWindow - outstanding);
2148 auto txn = httpSession_->newTransaction(&handler);
2149 txn->sendHeaders(req);
2154 httpSession_->dropConnection();
2162 auto txn = httpSession_->newTransaction(&handler);
2163 txn->sendHeadersWithEOM(req);
2166 httpSession_->dropConnection();
2169 template <
int stage>
2187 std::unique_ptr<HTTPMessage> resp;
2188 std::unique_ptr<folly::IOBuf> respBody;
2191 handler.expectTransaction();
2195 handler.expectHeaders();
2210 handler.expectEOM();
2213 auto txn = httpSession_->newTransaction(&handler);
2215 txn->sendHeaders(req);
2218 auto doAbort = [&] {
2219 EXPECT_CALL(*codecPtr_, generateRstStream(
_, txn->getID(),
_));
2220 handler.expectDetachTransaction();
2221 const auto id = txn->getID();
2224 generateRstStream(
_,
id, ErrorCode::_SPDY_INVALID_STREAM))
2243 codecCb_->onChunkComplete(
streamID);
2247 codecCb_->onTrailersComplete(
streamID,
2248 std::make_unique<HTTPHeaders>());
2252 codecCb_->onMessageComplete(
streamID,
false);
2279 handler.expectTransaction();
2282 auto txn = httpSession_->newTransaction(&handler);
2283 const auto streamID = txn->getID();
2284 txn->sendHeaders(req);
2287 handler.expectHeaders();
2291 handler.expectDetachTransaction();
2293 ErrorCode::_SPDY_INVALID_STREAM));
2295 codecCb_->onMessageComplete(
streamID,
true);
2297 ErrorCode::_SPDY_INVALID_STREAM));
2298 codecCb_->onMessageComplete(
streamID,
false);
2309 auto handler = openTransaction();
2314 handler->expectDetachTransaction();
2316 httpSession_->drain();
2319 codecCb_->onMessageComplete(
handler->txn_->getID(),
false);
2331 auto handler1 = openTransaction();
2332 auto handler2 = openTransaction();
2335 handler1->expectGoaway();
2336 handler2->expectGoaway();
2337 codecCb_->onGoaway(101, ErrorCode::NO_ERROR);
2340 handler1->txn_->sendHeaders(req);
2343 handler1->expectGoaway();
2344 handler2->expectGoaway();
2349 folly::to<std::string>(
"StreamUnacknowledged on transaction id: ",
2350 handler2->txn_->getID()),
2353 handler2->expectDetachTransaction();
2354 codecCb_->onGoaway(handler1->txn_->getID(), ErrorCode::NO_ERROR);
2357 httpSession_->drain();
2358 EXPECT_CALL(*codecPtr_, generateRstStream(
_, handler1->txn_->getID(),
_));
2359 handler1->expectDetachTransaction();
2360 handler1->txn_->sendAbort();
2369 auto handler = openTransaction();
2372 int pushID = streamID + 1;
2373 int badAssocID = streamID + 2;
2376 generateRstStream(
_, pushID, ErrorCode::PROTOCOL_ERROR));
2378 generateRstStream(
_, pushID, ErrorCode::_SPDY_INVALID_STREAM))
2382 codecCb_->onPushMessageBegin(pushID, badAssocID, resp.get());
2383 codecCb_->onHeadersComplete(pushID,
std::move(resp));
2384 codecCb_->onMessageComplete(pushID,
false);
2386 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2393 codecCb_->onMessageBegin(streamID, resp.get());
2394 codecCb_->onHeadersComplete(streamID,
std::move(resp));
2395 codecCb_->onMessageComplete(streamID,
false);
2402 EXPECT_TRUE(!httpSession_->hasActiveTransactions());
2403 httpSession_->destroy();
2411 auto handler = openTransaction();
2414 int pushID = streamID + 1;
2416 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2423 codecCb_->onMessageBegin(streamID, resp.get());
2424 codecCb_->onHeadersComplete(streamID,
std::move(resp));
2425 codecCb_->onMessageComplete(streamID,
false);
2428 generateRstStream(
_, pushID, ErrorCode::PROTOCOL_ERROR))
2431 EXPECT_TRUE(httpSession_->hasActiveTransactions());
2435 generateRstStream(
_, pushID, ErrorCode::_SPDY_INVALID_STREAM))
2439 codecCb_->onPushMessageBegin(pushID, streamID, resp.get());
2440 codecCb_->onHeadersComplete(pushID,
std::move(resp));
2441 codecCb_->onMessageComplete(pushID,
false);
2448 EXPECT_TRUE(!httpSession_->hasActiveTransactions());
2449 httpSession_->destroy();
2457 auto handler = openTransaction();
2460 int pushID = streamID + 1;
2468 generateRstStream(
_, pushID, ErrorCode::REFUSED_STREAM));
2470 generateRstStream(
_, pushID, ErrorCode::_SPDY_INVALID_STREAM))
2473 auto resp = std::make_unique<HTTPMessage>();
2474 resp->setStatusCode(200);
2475 resp->setStatusMessage(
"OK");
2476 codecCb_->onPushMessageBegin(pushID, streamID, resp.get());
2477 codecCb_->onHeadersComplete(pushID,
std::move(resp));
2478 codecCb_->onMessageComplete(pushID,
false);
2480 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2486 resp = std::make_unique<HTTPMessage>();
2487 resp->setStatusCode(200);
2488 resp->setStatusMessage(
"OK");
2489 codecCb_->onMessageBegin(streamID, resp.get());
2490 codecCb_->onHeadersComplete(streamID,
std::move(resp));
2491 codecCb_->onMessageComplete(streamID,
false);
2498 EXPECT_TRUE(!httpSession_->hasActiveTransactions());
2499 httpSession_->destroy();
2507 auto handler = openTransaction();
2510 int pushID = streamID + 1;
2513 handler->txn_->setHandler(
nullptr);
2516 generateRstStream(
_, pushID, ErrorCode::REFUSED_STREAM));
2518 generateRstStream(
_, pushID, ErrorCode::_SPDY_INVALID_STREAM))
2521 auto resp = std::make_unique<HTTPMessage>();
2522 resp->setStatusCode(200);
2523 resp->setStatusMessage(
"OK");
2524 codecCb_->onPushMessageBegin(pushID, streamID, resp.get());
2525 codecCb_->onHeadersComplete(pushID,
std::move(resp));
2526 codecCb_->onMessageComplete(pushID,
false);
2532 EXPECT_TRUE(!httpSession_->hasActiveTransactions());
2533 httpSession_->destroy();
2538 auto handler = openTransaction();
2539 handler->txn_->sendHeaders(req);
2547 ASSERT_EQ(
"Invalid ingress state transition, state=RegularBodyReceived, " 2548 "event=onHeaders, streamID=1",
2551 handler->expectDetachTransaction();
2553 codecCb_->onMessageBegin(1, resp.get());
2554 codecCb_->onHeadersComplete(1,
std::move(resp));
2555 codecCb_->onBody(1,
makeBuf(20), 0);
2562 EXPECT_CALL(*codecPtr_, supportsStreamFlowControl())
2563 .WillRepeatedly(
Return(
true));
2565 auto handler = openTransaction();
2566 handler->txn_->setReceiveWindow(1000000);
2573 handler->txn_->sendHeaders(req);
2574 handler->expectDetachTransaction();
2576 httpSession_->destroy();
2583 httpSession_->dropConnection();
2588 ASSERT_EQ(folly::to<std::string>(
"Dropped on transaction id: ",
2589 handler.txn_->getID()),
2592 handler.expectDetachTransaction();
2593 (void)httpSession_->newTransaction(&handler);
2604 .WillRepeatedly(
Return(
false));
2605 sock->addWaitingForReplaySafety(&cb1);
2606 sock->addWaitingForReplaySafety(&cb2);
2607 sock->addWaitingForReplaySafety(&cb3);
2608 sock->removeWaitingForReplaySafety(&cb2);
2611 .WillByDefault(
Return(
true));
2614 replaySafetyCallback_->onReplaySafe();
2616 httpSession_->destroy();
2625 .WillRepeatedly(
Return(
true));
2627 sock->addWaitingForReplaySafety(&cb);
2629 httpSession_->destroy();
2637 this->httpSession_->setInfoCallback(&infoCb);
2640 readCallback_->readBufferAvailable(
std::move(buf));
2642 httpSession_->destroy();
2659 egressCodec->generateConnectionPreface(output);
2660 egressCodec->generateSettings(output);
2662 for (
auto i = 0;
i < 2;
i++) {
2663 auto handler = openTransaction();
2664 handler->expectHeaders([&] (std::shared_ptr<HTTPMessage> msg) {
2669 handler->expectDetachTransaction();
2673 egressCodec->generateHeader(output,
handler->txn_->getID(), resp);
2674 egressCodec->generateBody(output,
handler->txn_->getID(),
makeBuf(20),
2675 HTTPCodec::NoPadding,
true );
2678 auto buf = output.
move();
2680 readAndLoop(buf.get());
2682 httpSession_->detachThreadLocals();
2683 httpSession_->attachThreadLocals(&base,
nullptr, timerInstance,
nullptr, fn,
2689 httpSession_->destroy();
2696 using AllTypes = ::testing::Types<HTTP1xCodecPair, SPDY3CodecPair>;
HTTPCodec::StreamID parentId_
TestAbortPost< 3 > TestAbortPost3
HTTP2UpstreamSessionWithPriorityTree()
virtual void setHandler(Handler *handler)
TimeoutableHTTPUpstreamTest()
virtual size_t onIngress(const folly::IOBuf &buf)=0
void setCallback(Callback *callback) override
~NoFlushUpstreamSessionTest() override
::testing::Types< HTTP1xCodecPair, SPDY3CodecPair > AllTypes
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
GTEST_API_ Cardinality AtLeast(int n)
HTTPUpstreamRecvStreamTest()
void onSettingsOutgoingStreamsFull(const HTTPSessionBase &) override
ProxygenError getProxygenError() const
#define ASSERT_EQ(val1, val2)
HTTPUpstreamTest(std::vector< int64_t > flowControl={-1,-1,-1})
TestAbortPost< 1 > TestAbortPost1
void setStatusMessage(T &&msg)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
EventBase * getEventBase()
HTTPMessage::HTTPPriority hiPri_
const uint8_t * data() const
void setProxygenError(ProxygenError proxygenError)
std::unique_ptr< folly::IOBuf > move()
static http_parser_settings settings
MockByteEventTracker * setMockByteEventTracker()
—— Concurrent Priority Queue Implementation ——
void setCodecStatusCode(ErrorCode statusCode)
static int DEFAULT_TICK_INTERVAL
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
const HeaderIndexingStrategy * getHeaderIndexingStrategy() const
HTTPMessage::HTTPPriority loPri_
void readAndLoop(const uint8_t *input, size_t length)
void onCreate(const HTTPSessionBase &) override
void parseOutput(HTTPCodec &serverCodec)
std::unique_ptr< StrictMock< MockHTTPHandler > > openTransaction(bool expectStartPaused=false)
void handler(int, siginfo_t *, void *)
std::unique_ptr< folly::IOBuf > makeBuf(uint32_t size)
REGISTER_TYPED_TEST_CASE_P(HTTPUpstreamTest, ImmediateEof)
void testSimpleUpgrade(const std::string &upgradeReqHeader, const std::string &upgradeRespHeader, CodecProtocol respCodecVersion)
size_t generateBody(folly::IOBufQueue &writeBuf, StreamID stream, std::unique_ptr< folly::IOBuf > chain, folly::Optional< uint8_t > padding, bool eom) override
virtual void onWriteChain(folly::AsyncTransportWrapper::WriteCallback *callback, std::shared_ptr< IOBuf > iob, WriteFlags)
HTTPMessage::HTTPPriority minPriority_
std::unique_ptr< StrictMock< MockHTTPHandler > > openTransaction()
void writeBuf(const Buf &buf, folly::io::Appender &out)
static UniquePtr newTimer(Args &&...args)
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
void readAndLoop(const std::string &input)
static Options cacheChainLength()
Direction getDirection() const
bool loopOnce(int flags=0)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
unique_ptr< typename C::Codec > makeServerCodec()
static UniquePtr makeUnique(Args &&...args)
void setFlowControl(size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize) override
std::size_t length() const
TestAbortPost< 0 > TestAbortPost0
void incrementPendingByteEvents()
virtual uint32_t getDefaultWindowSize() const
void expectEOM(std::function< void()> callback=std::function< void()>())
wangle::TransportInfo mockTransportInfo_
TestAbortPost< 4 > TestAbortPost4
HTTPMessage getResponse(uint32_t code, uint32_t bodyLen)
MockAsyncTransport * transport_
void generatePushPromise(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, StreamID assocstream, bool eom=false, HTTPHeaderSize *size=nullptr) override
std::vector< folly::AsyncTransportWrapper::WriteCallback * > cbs_
HTTPCodec::StreamID loPriId_
HTTPHeaders & getHeaders()
std::vector< HTTPCodec::StreamID > dependencies
void expectDetachTransaction(std::function< void()> callback=std::function< void()>())
std::unique_ptr< HHWheelTimer, Destructor > UniquePtr
std::unique_ptr< HTTPMessage > makeResponse(uint16_t statusCode)
void onSettingsOutgoingStreamsNotFull(const HTTPSessionBase &) override
TYPED_TEST_CASE_P(HTTPUpstreamTest)
bool hasProxygenError() const
TEST_F(AsyncSSLSocketWriteTest, write_coalescing1)
void expectTransaction(std::function< void(HTTPTransaction *txn)> callback)
void expectHeaders(std::function< void()> callback=std::function< void()>())
std::size_t computeChainDataLength() const
void enableExHeader(typename C::Codec *serverCodec)
std::unique_ptr< NiceMock< MockHTTPHandler > > openNiceTransaction(bool expectStartPaused=false)
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
#define EXPECT_TRUE(condition)
std::shared_ptr< TestPriorityMapBuilder > builder_
void commonSetUp(unique_ptr< HTTPCodec > codec)
std::vector< HTTPSetting > SettingsList
#define ON_CALL(obj, call)
std::enable_if< std::is_enum< Version >::value, std::unique_ptr< MyCodec > >::type makeServerCodec(Version version)
virtual folly::Optional< const HTTPMessage::HTTPPriority > getHTTPPriority(uint8_t level) override
void onDestroy(const HTTPSessionBase &) override
HTTPMessage getGetRequest(const std::string &url)
AsyncFizzClient::UniquePtr transport_
std::vector< int64_t > flowControl_
TestAbortPost< 2 > TestAbortPost2
HTTPMessage getPostRequest(uint32_t contentLength)
void setHTTPVersion(uint8_t major, uint8_t minor)
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
void onWriteChain(folly::AsyncTransportWrapper::WriteCallback *callback, std::shared_ptr< IOBuf >, WriteFlags) override
void commonSetUp(unique_ptr< HTTPCodec > codec)
void handleWrite(folly::AsyncTransportWrapper::WriteCallback *callback)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
virtual void writeSuccess() noexcept=0
HTTPCodec::StreamID hiPriId_
virtual void writeErr(size_t bytesWritten, const AsyncSocketException &ex) noexcept=0
TYPED_TEST_P(HTTPUpstreamTest, ImmediateEof)
#define ASSERT_NE(val1, val2)
HTTPMessage getUpgradeRequest(const std::string &upgradeHeader, HTTPMethod method, uint32_t bodyLen)
void testBasicRequestHttp10(bool keepalive)
#define EXPECT_FALSE(condition)
folly::HHWheelTimer::UniquePtr transactionTimeouts_
virtual HTTPCodec::StreamID sendPriority(http2::PriorityUpdate pri)=0
#define EXPECT_LT(val1, val2)
virtual std::unique_ptr< HTTPUpstreamSession::PriorityAdapter > createVirtualStreams(HTTPPriorityMapFactoryProvider *session) const override
HTTPCodec::StreamID getID() const
INSTANTIATE_TYPED_TEST_CASE_P(AllTypesPrefix, HTTPUpstreamTest, AllTypes)
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
void generateHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom=false, HTTPHeaderSize *size=nullptr) override
TestAbortPost< 5 > TestAbortPost5
const char * what(void) const noexceptoverride
#define ASSERT_TRUE(condition)
std::unique_ptr< Codec > getCodec(CodecType type, int level)
std::vector< folly::AsyncTransportWrapper::WriteCallback * > cbs_
void expectBody(std::function< void()> callback=std::function< void()>())
void readAndLoop(IOBuf *buf)
internal::ReturnAction< R > Return(R value)
size_t generateGoaway(folly::IOBufQueue &writeBuf, StreamID lastStream, ErrorCode statusCode, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
std::map< uint8_t, HTTPMessage::HTTPPriority > priorityMap_
uint32_t getDefaultWindowSize() const override
void setStatusCode(uint16_t status)