invoke ::generateEOM from ::generateTrailers
Some checks are pending
linux / build (push) Waiting to run
mac / build (push) Waiting to run

Summary:
::generateTrailers is a terminal "event" on a http1x chunked upstream req / downstream resp

Put another way – after invoking ::generateTrailers, nothing else can be egressed w.r.t. to the txn; this is enforced by HTTPTransactionEgressSM

Reviewed By: jbeshay, kvtsoy

Differential Revision: D70193047

fbshipit-source-id: 1d19fc86496d4fb06ed1bd0e493a22b12b2f355c
This commit is contained in:
Hani Damlaj 2025-03-03 19:10:51 -08:00 committed by Facebook GitHub Bot
parent bbfe19d8a4
commit 788029d7a1
3 changed files with 4 additions and 12 deletions

View File

@ -789,6 +789,7 @@ size_t HTTP1xCodec::generateTrailers(IOBufQueue& writeBuf,
appendString(writeBuf, len, value);
appendLiteral(writeBuf, len, CRLF);
});
len += generateEOM(writeBuf, txn);
}
return len;
}
@ -804,10 +805,7 @@ size_t HTTP1xCodec::generateEOM(IOBufQueue& writeBuf, StreamID txn) {
// appending a 0\r\n only if it's not a HEAD and downstream request
if (!lastChunkWritten_) {
lastChunkWritten_ = true;
if (!(headRequest_ &&
transportDirection_ == TransportDirection::DOWNSTREAM)) {
appendLiteral(writeBuf, len, "0\r\n");
}
appendLiteral(writeBuf, len, "0\r\n");
}
appendLiteral(writeBuf, len, CRLF);
}

View File

@ -873,7 +873,6 @@ TEST(HTTP1xCodecTest, TestChunkResponseSerialization) {
downCodec.generateBody(
blob, downStream, body->clone(), HTTPCodec::NoPadding, false);
downCodec.generateTrailers(blob, downStream, trailers);
downCodec.generateEOM(blob, downStream);
std::string tmp;
blob.appendToString(tmp);

View File

@ -1846,13 +1846,8 @@ size_t HTTPSession::sendEOM(HTTPTransaction* txn,
size_t encodedSize = 0;
if (trailers) {
encodedSize = codec_->generateTrailers(writeBuf_, txn->getID(), *trailers);
}
// Don't send EOM for HTTP2, when trailers sent.
// sendTrailers already flagged end of stream.
bool http2Trailers = trailers && isHTTP2CodecProtocol(codec_->getProtocol());
if (!http2Trailers) {
encodedSize += codec_->generateEOM(writeBuf_, txn->getID());
} else {
encodedSize = codec_->generateEOM(writeBuf_, txn->getID());
}
commonEom(txn, encodedSize, false);