Http2: move assemble_hpack_block declaration to header
Change-Id: I5033d433d2aa499007a6e436dbb70d9c48315e8b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 8ce261f6d857e8b05c8043042fce101cb95cd868) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b9640c0ecf
commit
72c2d67250
@ -197,6 +197,33 @@ bool is_protocol_upgraded(const QHttpNetworkReply &reply)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uchar> assemble_hpack_block(const std::vector<Frame> &frames)
|
||||||
|
{
|
||||||
|
std::vector<uchar> hpackBlock;
|
||||||
|
|
||||||
|
quint32 total = 0;
|
||||||
|
for (const auto &frame : frames) {
|
||||||
|
if (qAddOverflow(total, frame.hpackBlockSize(), &total))
|
||||||
|
return hpackBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!total)
|
||||||
|
return hpackBlock;
|
||||||
|
|
||||||
|
hpackBlock.resize(total);
|
||||||
|
auto dst = hpackBlock.begin();
|
||||||
|
for (const auto &frame : frames) {
|
||||||
|
if (const auto hpackBlockSize = frame.hpackBlockSize()) {
|
||||||
|
const uchar *src = frame.hpackBlockBegin();
|
||||||
|
std::copy(src, src + hpackBlockSize, dst);
|
||||||
|
dst += hpackBlockSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hpackBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Http2
|
} // namespace Http2
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <QtCore/private/qglobal_p.h>
|
#include <QtCore/private/qglobal_p.h>
|
||||||
#include <QtCore/qmap.h>
|
#include <QtCore/qmap.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
// Different HTTP/2 constants/values as defined by RFC 7540.
|
// Different HTTP/2 constants/values as defined by RFC 7540.
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -118,6 +120,7 @@ const qint32 qtDefaultStreamReceiveWindowSize = maxSessionReceiveWindowSize / 10
|
|||||||
struct Frame configurationToSettingsFrame(const QHttp2Configuration &configuration);
|
struct Frame configurationToSettingsFrame(const QHttp2Configuration &configuration);
|
||||||
QByteArray settingsFrameToBase64(const Frame &settingsFrame);
|
QByteArray settingsFrameToBase64(const Frame &settingsFrame);
|
||||||
void appendProtocolUpgradeHeaders(const QHttp2Configuration &configuration, QHttpNetworkRequest *request);
|
void appendProtocolUpgradeHeaders(const QHttp2Configuration &configuration, QHttpNetworkRequest *request);
|
||||||
|
std::vector<uchar> assemble_hpack_block(const std::vector<Frame> &frames);
|
||||||
|
|
||||||
extern const Q_AUTOTEST_EXPORT char Http2clientPreface[clientPrefaceLength];
|
extern const Q_AUTOTEST_EXPORT char Http2clientPreface[clientPrefaceLength];
|
||||||
|
|
||||||
|
@ -88,32 +88,6 @@ HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxH
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uchar> assemble_hpack_block(const std::vector<Http2::Frame> &frames)
|
|
||||||
{
|
|
||||||
std::vector<uchar> hpackBlock;
|
|
||||||
|
|
||||||
quint32 total = 0;
|
|
||||||
for (const auto &frame : frames) {
|
|
||||||
if (qAddOverflow(total, frame.hpackBlockSize(), &total))
|
|
||||||
return hpackBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!total)
|
|
||||||
return hpackBlock;
|
|
||||||
|
|
||||||
hpackBlock.resize(total);
|
|
||||||
auto dst = hpackBlock.begin();
|
|
||||||
for (const auto &frame : frames) {
|
|
||||||
if (const auto hpackBlockSize = frame.hpackBlockSize()) {
|
|
||||||
const uchar *src = frame.hpackBlockBegin();
|
|
||||||
std::copy(src, src + hpackBlockSize, dst);
|
|
||||||
dst += hpackBlockSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hpackBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
QUrl urlkey_from_request(const QHttpNetworkRequest &request)
|
QUrl urlkey_from_request(const QHttpNetworkRequest &request)
|
||||||
{
|
{
|
||||||
QUrl url;
|
QUrl url;
|
||||||
@ -962,7 +936,7 @@ void QHttp2ProtocolHandler::handleContinuedHEADERS()
|
|||||||
// has yet to see the reset.
|
// has yet to see the reset.
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uchar> hpackBlock(assemble_hpack_block(continuedFrames));
|
std::vector<uchar> hpackBlock(Http2::assemble_hpack_block(continuedFrames));
|
||||||
const bool hasHeaderFields = !hpackBlock.empty();
|
const bool hasHeaderFields = !hpackBlock.empty();
|
||||||
if (hasHeaderFields) {
|
if (hasHeaderFields) {
|
||||||
HPack::BitIStream inputStream{&hpackBlock[0], &hpackBlock[0] + hpackBlock.size()};
|
HPack::BitIStream inputStream{&hpackBlock[0], &hpackBlock[0] + hpackBlock.size()};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user