diff options
-rw-r--r-- | src/network/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/network/access/qnetworkreply.cpp | 10 | ||||
-rw-r--r-- | src/network/access/qnetworkreply.h | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.cpp | 10 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.h | 6 | ||||
-rw-r--r-- | src/network/compat/removed_api.cpp | 40 |
7 files changed, 68 insertions, 13 deletions
diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 3f1e9ccd49..4437946ab5 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -26,6 +26,7 @@ qt_internal_add_module(Network access/qnetworkreplyfileimpl.cpp access/qnetworkreplyfileimpl_p.h access/qnetworkreplyimpl.cpp access/qnetworkreplyimpl_p.h access/qnetworkrequest.cpp access/qnetworkrequest.h access/qnetworkrequest_p.h + compat/removed_api.cpp kernel/qauthenticator.cpp kernel/qauthenticator.h kernel/qauthenticator_p.h kernel/qhostaddress.cpp kernel/qhostaddress.h kernel/qhostaddress_p.h kernel/qhostinfo.cpp kernel/qhostinfo.h kernel/qhostinfo_p.h @@ -64,6 +65,8 @@ qt_internal_add_module(Network Qt::Core PRIVATE_MODULE_INTERFACE Qt::CorePrivate + NO_PCH_SOURCES + compat/removed_api.cpp PRECOMPILED_HEADER "../corelib/global/qt_pch.h" GENERATE_CPP_EXPORTS diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index 335a0131ff..2bd0003aa5 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -612,8 +612,9 @@ QVariant QNetworkReply::header(QNetworkRequest::KnownHeaders header) const the remote server \sa rawHeader() + \note In Qt versions prior to 6.7, this function took QByteArray only. */ -bool QNetworkReply::hasRawHeader(const QByteArray &headerName) const +bool QNetworkReply::hasRawHeader(QByteArrayView headerName) const { Q_D(const QNetworkReply); return d->findRawHeader(headerName) != d->rawHeaders.constEnd(); @@ -627,13 +628,12 @@ bool QNetworkReply::hasRawHeader(const QByteArray &headerName) const header field. \sa setRawHeader(), hasRawHeader(), header() + \note In Qt versions prior to 6.7, this function took QByteArray only. */ -QByteArray QNetworkReply::rawHeader(const QByteArray &headerName) const +QByteArray QNetworkReply::rawHeader(QByteArrayView headerName) const { Q_D(const QNetworkReply); - QNetworkHeadersPrivate::RawHeadersList::ConstIterator it = - d->findRawHeader(headerName); - if (it != d->rawHeaders.constEnd()) + if (const auto it = d->findRawHeader(headerName); it != d->rawHeaders.constEnd()) return it->second; return QByteArray(); } diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 2a505b07c0..705c5b32ea 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -97,9 +97,15 @@ public: QVariant header(QNetworkRequest::KnownHeaders header) const; // raw headers: +#if QT_NETWORK_REMOVED_SINCE(6, 7) bool hasRawHeader(const QByteArray &headerName) const; +#endif + bool hasRawHeader(QByteArrayView headerName) const; QList<QByteArray> rawHeaderList() const; +#if QT_NETWORK_REMOVED_SINCE(6, 7) QByteArray rawHeader(const QByteArray &headerName) const; +#endif + QByteArray rawHeader(QByteArrayView headerName) const; typedef QPair<QByteArray, QByteArray> RawHeaderPair; const QList<RawHeaderPair>& rawHeaderPairs() const; diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 70533a229e..7e4fbf7404 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1314,7 +1314,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"_ba); + QByteArray header = q->rawHeader("location"); QUrl url = QUrl(QString::fromUtf8(header)); if (!url.isValid()) url = QUrl(QLatin1StringView(header)); @@ -1358,7 +1358,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte // A user having manually defined which encodings they accept is, for // somwehat unknown (presumed legacy compatibility) reasons treated as // disabling our decompression: - const bool autoDecompress = request.rawHeader("accept-encoding"_ba).isEmpty(); + const bool autoDecompress = request.rawHeader("accept-encoding").isEmpty(); const bool shouldDecompress = isCompressed && autoDecompress; // reconstruct the HTTP header for (const auto &[key, originValue] : hm) { @@ -1859,7 +1859,7 @@ bool QNetworkReplyHttpImplPrivate::canResume() const return false; // Can only resume if server/resource supports Range header. - const auto acceptRangesheaderName = "Accept-Ranges"_ba; + constexpr auto acceptRangesheaderName = QByteArrayView("Accept-Ranges"); if (!q->hasRawHeader(acceptRangesheaderName) || q->rawHeader(acceptRangesheaderName) == "none") return false; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 634a10d4a9..9c13d5474d 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -617,8 +617,9 @@ void QNetworkRequest::setHeader(KnownHeaders header, const QVariant &value) network request. \sa rawHeader(), setRawHeader() + \note In Qt versions prior to 6.7, this function took QByteArray only. */ -bool QNetworkRequest::hasRawHeader(const QByteArray &headerName) const +bool QNetworkRequest::hasRawHeader(QByteArrayView headerName) const { return d->findRawHeader(headerName) != d->rawHeaders.constEnd(); } @@ -632,12 +633,11 @@ bool QNetworkRequest::hasRawHeader(const QByteArray &headerName) const Raw headers can be set with setRawHeader() or with setHeader(). \sa header(), setRawHeader() + \note In Qt versions prior to 6.7, this function took QByteArray only. */ -QByteArray QNetworkRequest::rawHeader(const QByteArray &headerName) const +QByteArray QNetworkRequest::rawHeader(QByteArrayView headerName) const { - QNetworkHeadersPrivate::RawHeadersList::ConstIterator it = - d->findRawHeader(headerName); - if (it != d->rawHeaders.constEnd()) + if (const auto it = d->findRawHeader(headerName); it != d->rawHeaders.constEnd()) return it->second; return QByteArray(); } diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index 2e7456b9a5..9ac3065ed6 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -118,9 +118,15 @@ public: void setHeader(KnownHeaders header, const QVariant &value); // raw headers: +#if QT_NETWORK_REMOVED_SINCE(6, 7) bool hasRawHeader(const QByteArray &headerName) const; +#endif + bool hasRawHeader(QByteArrayView headerName) const; QList<QByteArray> rawHeaderList() const; +#if QT_NETWORK_REMOVED_SINCE(6, 7) QByteArray rawHeader(const QByteArray &headerName) const; +#endif + QByteArray rawHeader(QByteArrayView headerName) const; void setRawHeader(const QByteArray &headerName, const QByteArray &value); // attributes diff --git a/src/network/compat/removed_api.cpp b/src/network/compat/removed_api.cpp new file mode 100644 index 0000000000..f445556c19 --- /dev/null +++ b/src/network/compat/removed_api.cpp @@ -0,0 +1,40 @@ +// Copyright (c) 2023 LLC «V Kontakte» +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#define QT_NETWORK_BUILD_REMOVED_API + +#include "qtnetworkglobal.h" + +QT_USE_NAMESPACE + +#if QT_NETWORK_REMOVED_SINCE(6, 7) + +#include "qnetworkreply.h" + +QByteArray QNetworkReply::rawHeader(const QByteArray &headerName) const +{ + return rawHeader(qToByteArrayViewIgnoringNull(headerName)); +} + +bool QNetworkReply::hasRawHeader(const QByteArray &headerName) const +{ + return hasRawHeader(qToByteArrayViewIgnoringNull(headerName)); +} + +#include "qnetworkrequest.h" + +QByteArray QNetworkRequest::rawHeader(const QByteArray &headerName) const +{ + return rawHeader(qToByteArrayViewIgnoringNull(headerName)); +} + +bool QNetworkRequest::hasRawHeader(const QByteArray &headerName) const +{ + return hasRawHeader(qToByteArrayViewIgnoringNull(headerName)); +} + +// #include "qotherheader.h" +// // implement removed functions from qotherheader.h +// order sections alphabetically + +#endif // QT_NETWORK_REMOVED_SINCE(6, 7) |