From 8f6b30ec8d5faf1ff413cd842069fccda869c4b6 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 10 Oct 2023 15:25:36 +0300 Subject: [PATCH] QNetworkReplyHttpImplPrivate: de-duplicate literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While touching code, use CaseInsensitive compare more to avoid needless tmp allocation Change-Id: I4fe8496133925887df6879b48c730c36f486fa9c Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qnetworkreplyhttpimpl.cpp | 8 +++++--- 1 file 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 QListfirst.compare("location", Qt::CaseInsensitive)) + !it->first.compare(locationHeader(), Qt::CaseInsensitive)) redirectUrl = QUrl::fromEncoded(it->second); setRawHeader(it->first, it->second); }