Skip to content

Commit 1339080

Browse files
hanidamlajfacebook-github-bot
authored andcommitted
add acceptor config for server early return
Summary: * adds a new member field in AcceptorConfiguration to enable server early response * for now, only enabled if underlying protocol is http/2 Reviewed By: afrind Differential Revision: D67123903 fbshipit-source-id: e9689550ed7b7840c2d817caab9e9609d47eee13
1 parent 358e8ea commit 1339080

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

proxygen/lib/http/session/HTTPSessionAcceptor.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void HTTPSessionAcceptor::onNewConnection(folly::AsyncTransport::UniquePtr sock,
9090
auto sessionInfoCb = sessionInfoCb_ ? sessionInfoCb_ : this;
9191
VLOG(4) << "Created new " << nextProtocol << " session for peer "
9292
<< *peerAddress;
93+
auto codecProtocol = codec->getProtocol();
9394
HTTPDownstreamSession* session =
9495
new HTTPDownstreamSession(getTransactionTimeoutSet(),
9596
std::move(sock),
@@ -113,6 +114,11 @@ void HTTPSessionAcceptor::onNewConnection(folly::AsyncTransport::UniquePtr sock,
113114
session->setFlowControl(getConfig()->initialReceiveWindow,
114115
getConfig()->receiveStreamWindowSize,
115116
getConfig()->receiveSessionWindowSize);
117+
// TODO(@damlaj): support server early resp for http/3
118+
if (getConfig()->serverEarlyResponseEnabled &&
119+
codecProtocol == CodecProtocol::HTTP_2) {
120+
session->enableServerEarlyResponse();
121+
}
116122
if (getConfig()->writeBufferLimit > 0) {
117123
session->setWriteBufferLimit(getConfig()->writeBufferLimit);
118124
}

proxygen/lib/services/AcceptorConfiguration.h

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ struct AcceptorConfiguration : public wangle::ServerSocketConfig {
9696
**/
9797
bool HTTP2PingEnabled{false};
9898

99+
/**
100+
* When the server sends a complete response prior to the client sending an
101+
* entire request (for non-upgraded streams), the server will subsequently
102+
* write RST_STREAM/NO_ERROR (h2) or STOP_SENDING/NO_ERROR (h3). This has no
103+
* effect in http/1.1.
104+
*/
105+
bool serverEarlyResponseEnabled{false};
106+
99107
/* Strategy for which headers to insert into HPACK/QPACK dynamic table */
100108
const HeaderIndexingStrategy* headerIndexingStrategy{nullptr};
101109
};

0 commit comments

Comments
 (0)