Skip to content

Commit 328583c

Browse files
authored
More update to HTTP/2 client (#2428)
* allow unknown frames * clean up round robin sending logic
1 parent d9420f1 commit 328583c

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

ChangeLog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7-
## [1.10.0-beta.3] - TBD
7+
## [1.10.0-beta.4] - TBD
8+
9+
### Fixes
10+
11+
* Correctly track received bytes in HTTP/2 client statistics
12+
* Ignore unknown HTTP/2 frame types instead of treating them as fatal errors (forward compatibility)
13+
14+
## [1.10.0-beta.3] - 2025-12-21
815

916
### Changes
1017

lib/src/Http2Transport.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,13 @@ parseH2Frame(trantor::MsgBuffer *msg)
625625
// MSB is reserved for future use
626626
const uint32_t streamId = header.readU32BE() & ((1U << 31) - 1);
627627

628-
if (type >= (uint8_t)H2FrameType::NumEntries)
629-
{
630-
// TODO: Handle fatal protocol error
631-
LOG_TRACE << "Unsupported H2 frame type: " << (int)type;
632-
return {std::nullopt, streamId, 0, true, 0};
633-
}
628+
// This check is not need as HTTP/2 allows unknown frame types to be
629+
// ignored for forward compatibility.
630+
// if (type >= (uint8_t)H2FrameType::NumEntries)
631+
// {
632+
// LOG_TRACE << "Unsupported H2 frame type: " << (int)type;
633+
// return {std::nullopt, streamId, 0, true, 0};
634+
// }
634635

635636
LOG_TRACE << "H2 frame: length=" << length << " type=" << (int)type
636637
<< " flags=" << (int)flags << " streamId=" << streamId;
@@ -657,7 +658,7 @@ parseH2Frame(trantor::MsgBuffer *msg)
657658
frame = RstStreamFrame::parse(payload, flags);
658659
else
659660
{
660-
LOG_WARN << "Unsupported H2 frame type: " << (int)type;
661+
LOG_TRACE << "Unsupported H2 frame type: " << (int)type;
661662
msg->retrieve(length + 9);
662663
return {std::nullopt, streamId, 0, false, 0};
663664
}
@@ -976,28 +977,27 @@ void Http2Transport::onRecvMessage(const trantor::TcpConnectionPtr &,
976977
auto it = currentDataSend.value_or(pendingDataSend.begin());
977978
while (it != pendingDataSend.end())
978979
{
979-
auto &stream = streams[it->first];
980-
auto [sentOffset, done] = sendBodyForStream(stream, it->second);
980+
auto streamIt = streams.find(it->first);
981+
assert(streamIt != streams.end()); // FATAL: must exist
982+
auto [sentOffset, done] =
983+
sendBodyForStream(streamIt->second, it->second);
981984
if (done)
982985
{
983986
it = pendingDataSend.erase(it);
984-
if (it != pendingDataSend.end())
985-
currentDataSend = it;
986-
else
987+
if (it == pendingDataSend.end())
987988
{
988989
currentDataSend = std::nullopt;
989990
break;
990991
}
992+
currentDataSend = it;
991993
continue;
992994
}
993995
it->second = sentOffset;
994-
if (availableTxWindow != 0)
995-
{
996-
++it;
997-
currentDataSend = it;
998-
}
999-
else
996+
if (availableTxWindow == 0)
1000997
break;
998+
999+
++it;
1000+
currentDataSend = it;
10011001
}
10021002
}
10031003
else if (std::holds_alternative<SettingsFrame>(frame))

0 commit comments

Comments
 (0)