mirror of https://github.com/qt/qtgrpc.git
Cache the :scheme HTTP/2 header
It's not mutable during QGrpcHttp2ChannelPrivate lifetime, so we may cache it. Pick-to: 6.8 6.9 Change-Id: I2b84a4ec46acfca488d00d527e180a6e3fc430f1 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
7d939f6e2e
commit
073429bfb1
|
|
@ -269,6 +269,7 @@ public:
|
||||||
[[nodiscard]] const QByteArray &contentType() const { return m_contentType; }
|
[[nodiscard]] const QByteArray &contentType() const { return m_contentType; }
|
||||||
|
|
||||||
[[nodiscard]] const QByteArray &authorityHeader() const { return m_authorityHeader; }
|
[[nodiscard]] const QByteArray &authorityHeader() const { return m_authorityHeader; }
|
||||||
|
[[nodiscard]] const QByteArray &schemeHeader() const { return m_schemeHeader; }
|
||||||
|
|
||||||
std::shared_ptr<QAbstractProtobufSerializer> serializer;
|
std::shared_ptr<QAbstractProtobufSerializer> serializer;
|
||||||
QUrl hostUri;
|
QUrl hostUri;
|
||||||
|
|
@ -314,6 +315,7 @@ private:
|
||||||
std::function<void()> m_reconnectFunction;
|
std::function<void()> m_reconnectFunction;
|
||||||
|
|
||||||
QByteArray m_authorityHeader;
|
QByteArray m_authorityHeader;
|
||||||
|
QByteArray m_schemeHeader;
|
||||||
Q_DISABLE_COPY_MOVE(QGrpcHttp2ChannelPrivate)
|
Q_DISABLE_COPY_MOVE(QGrpcHttp2ChannelPrivate)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -465,8 +467,7 @@ void Http2Handler::prepareInitialRequest(QGrpcOperationContext *operationContext
|
||||||
{ AuthorityHeader.toByteArray(), channel->authorityHeader() },
|
{ AuthorityHeader.toByteArray(), channel->authorityHeader() },
|
||||||
{ MethodHeader.toByteArray(), "POST"_ba },
|
{ MethodHeader.toByteArray(), "POST"_ba },
|
||||||
{ PathHeader.toByteArray(), QByteArray('/' + service + '/' + method) },
|
{ PathHeader.toByteArray(), QByteArray('/' + service + '/' + method) },
|
||||||
{ SchemeHeader.toByteArray(),
|
{ SchemeHeader.toByteArray(), channel->schemeHeader() },
|
||||||
channel->isLocalSocket() ? "http"_ba : channel->hostUri.scheme().toLatin1() },
|
|
||||||
{ ContentTypeHeader.toByteArray(), channel->contentType() },
|
{ ContentTypeHeader.toByteArray(), channel->contentType() },
|
||||||
{ GrpcServiceNameHeader.toByteArray(), { service } },
|
{ GrpcServiceNameHeader.toByteArray(), { service } },
|
||||||
{ GrpcAcceptEncodingHeader.toByteArray(), "identity,deflate,gzip"_ba },
|
{ GrpcAcceptEncodingHeader.toByteArray(), "identity,deflate,gzip"_ba },
|
||||||
|
|
@ -749,6 +750,8 @@ QGrpcHttp2ChannelPrivate::QGrpcHttp2ChannelPrivate(const QUrl &uri, QGrpcHttp2Ch
|
||||||
m_authorityHeader += QByteArray::number(hostUri.port());
|
m_authorityHeader += QByteArray::number(hostUri.port());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_schemeHeader = isLocalSocket() ? "http"_ba : hostUri.scheme().toLatin1();
|
||||||
|
|
||||||
m_reconnectFunction();
|
m_reconnectFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue