summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDennis Oberst <[email protected]>2025-12-08 13:33:32 +0100
committerDennis Oberst <[email protected]>2025-12-12 17:50:50 +0100
commitb930577d1be273579c3ee15b326323b068c66e04 (patch)
tree78a06a2ea7792c645eff63efe72c6b1461fab754 /src
parentcfda12b43db18ebf17afa2d320fe4e43c378669b (diff)
QHttp2Stream: append message data before dataReceived()
... so that there is a way to access downloadBuffer() / takeDownloadBuffer() when the signal is emitting and not afterwards. Add the 'last()' functionality (c.f. QList::last) so that we can get a cheap reference to the just inserted buffer entry. Task-number: QTBUG-142473 Pick-to: 6.11 6.10 6.8 Change-Id: I263322ec8a83cd29294b60c139a1ec3dab698ecb Reviewed-by: Mate Barany <[email protected]> Reviewed-by: MÃ¥rten Nordheim <[email protected]> Reviewed-by: Alexey Edelev <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qbytedatabuffer_p.h2
-rw-r--r--src/network/access/qhttp2connection.cpp10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/network/access/qbytedatabuffer_p.h b/src/network/access/qbytedatabuffer_p.h
index a119093cf7e..036b562d06a 100644
--- a/src/network/access/qbytedatabuffer_p.h
+++ b/src/network/access/qbytedatabuffer_p.h
@@ -280,6 +280,8 @@ public:
}
return false;
}
+
+ const QByteArray &last() const { return buffers.last(); }
};
QT_END_NAMESPACE
diff --git a/src/network/access/qhttp2connection.cpp b/src/network/access/qhttp2connection.cpp
index 2895e8335d2..3f88318bb17 100644
--- a/src/network/access/qhttp2connection.cpp
+++ b/src/network/access/qhttp2connection.cpp
@@ -697,8 +697,14 @@ void QHttp2Stream::handleDATA(const Frame &inboundFrame)
inboundFrame.dataSize());
if (endStream)
transitionState(StateTransition::CloseRemote);
- emit dataReceived(fragment, endStream);
- m_downloadBuffer.append(std::move(fragment));
+ const auto shouldBuffer = !fragment.isEmpty();
+ if (shouldBuffer) {
+ // Only non-empty fragments get appended!
+ m_downloadBuffer.append(std::move(fragment));
+ emit dataReceived(m_downloadBuffer.last(), endStream);
+ } else {
+ emit dataReceived(fragment, endStream);
+ }
}
if (!endStream && m_recvWindow < connection->streamInitialReceiveWindowSize / 2) {