summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorAnton Kudryavtsev <anton.kudryavtsev@vk.team>2023-10-10 15:25:36 +0300
committerMårten Nordheim <marten.nordheim@qt.io>2023-11-01 20:05:38 +0000
commit8f6b30ec8d5faf1ff413cd842069fccda869c4b6 (patch)
treefb9bb61a31b6d6d41950f562546a9887cfef8bd6 /src/network/access/qnetworkreplyhttpimpl.cpp
parent0bd9265867853263f2a3961f3c3af62d8ef93e7d (diff)
QNetworkReplyHttpImplPrivate: de-duplicate literals
While touching code, use CaseInsensitive compare more to avoid needless tmp allocation Change-Id: I4fe8496133925887df6879b48c730c36f486fa9c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 7e4fbf7404..0fa4e24264 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1302,6 +1302,8 @@ void QNetworkReplyHttpImplPrivate::followRedirect()
q, [this]() { postRequest(redirectRequest); }, Qt::QueuedConnection);
}
+static constexpr QByteArrayView locationHeader() noexcept { return "location"; }
+
void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode)
{
Q_Q(QNetworkReplyHttpImpl);
@@ -1314,7 +1316,7 @@ void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode)
// What do we do about the caching of the HTML note?
// The response to a 303 MUST NOT be cached, while the response to
// all of the others is cacheable if the headers indicate it to be
- QByteArray header = q->rawHeader("location");
+ QByteArray header = q->rawHeader(locationHeader());
QUrl url = QUrl(QString::fromUtf8(header));
if (!url.isValid())
url = QUrl(QLatin1StringView(header));
@@ -1367,7 +1369,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte
// Reset any previous "location" header set in the reply. In case of
// redirects, we don't want to 'append' multiple location header values,
// rather we keep only the latest one
- if (key.toLower() == "location")
+ if (key.compare(locationHeader(), Qt::CaseInsensitive) == 0)
value.clear();
if (shouldDecompress && !decompressHelper.isValid()
@@ -1662,7 +1664,7 @@ bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData
QUrl redirectUrl;
for ( ; it != end; ++it) {
if (httpRequest.isFollowRedirects() &&
- !it->first.compare("location", Qt::CaseInsensitive))
+ !it->first.compare(locationHeader(), Qt::CaseInsensitive))
redirectUrl = QUrl::fromEncoded(it->second);
setRawHeader(it->first, it->second);
}