summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2024-01-10 13:37:53 +0200
committerJuha Vuolle <juha.vuolle@qt.io>2024-01-15 10:29:07 +0200
commit89dab8578c10ed4aee4e2f4b51e7c962d618c1eb (patch)
treed24bc0a7c441801f99f4918f1fde992e88eb0835 /src/network/access
parent2d9afc8501879a0ef39bc169cdf8d0b7fa9616f8 (diff)
Remove HTTP headers equals() / comparison
There's several ways to compare HTTP headers, and arguably the need for it is not very high. For the time being users can use different accessors and compare in ways that make sense for their use cases. Consequently since HTTP headers are no longer trivially comparable, it makes also comparing the request factories more 'moot' because headers are a central piece of request information. So removed comparison from request factory as well. These comparisons can be restored later if a clear understanding on it's need, and on how it should be best done, emerges. Resulted from API-review Pick-to: 6.7 Change-Id: Idb5ab3710268b52a8e59656db8cc7de82f0ae511 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpheaders.cpp46
-rw-r--r--src/network/access/qhttpheaders.h11
-rw-r--r--src/network/access/qnetworkrequestfactory.cpp45
-rw-r--r--src/network/access/qnetworkrequestfactory.h4
-rw-r--r--src/network/access/qnetworkrequestfactory_p.h1
5 files changed, 0 insertions, 107 deletions
diff --git a/src/network/access/qhttpheaders.cpp b/src/network/access/qhttpheaders.cpp
index 41897cacd5..7a4778f18a 100644
--- a/src/network/access/qhttpheaders.cpp
+++ b/src/network/access/qhttpheaders.cpp
@@ -90,9 +90,6 @@ class QHttpHeadersPrivate : public QSharedData
public:
QHttpHeadersPrivate() = default;
- bool equals(const QHttpHeadersPrivate &other,
- QHttpHeaders::CompareOptions options) const noexcept;
-
QList<Header> headers;
Q_ALWAYS_INLINE void verify([[maybe_unused]] qsizetype pos = 0,
@@ -107,18 +104,6 @@ public:
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QHttpHeadersPrivate)
-bool QHttpHeadersPrivate::equals(const QHttpHeadersPrivate &other,
- QHttpHeaders::CompareOptions options) const noexcept
-{
- if (headers.size() != other.headers.size())
- return false;
-
- if (options & QHttpHeaders::CompareOption::OrderSensitive)
- return headers == other.headers;
- else
- return std::is_permutation(headers.begin(), headers.end(), other.headers.begin());
-}
-
// This list is from IANA HTTP Field Name Registry
// https://www.iana.org/assignments/http-fields
// It contains entries that are either "permanent"
@@ -494,24 +479,6 @@ static constexpr auto headerNames = qOffsetStringArray(
*/
/*!
- \enum QHttpHeaders::CompareOption
-
- This enum type contains the options for comparing two
- QHttpHeaders instances.
-
- \value OrderInsensitive
- Specifies that the order of headers is not significant in the comparison.
- With this option, two QHttpHeaders instances will be considered equal
- if they contain the same headers regardless of their order. This is
- true with most HTTP headers and use cases.
-
- \value OrderSensitive
- Specifies that the order of headers is significant in the comparison.
- With this option, two QHttpHeaders instances will be considered equal
- only if they contain the same headers in the same exact order.
-*/
-
-/*!
Creates a new QHttpHeaders object.
*/
QHttpHeaders::QHttpHeaders() : d(new QHttpHeadersPrivate)
@@ -1075,19 +1042,6 @@ void QHttpHeaders::reserve(qsizetype size)
}
/*!
- Compares this instance with \a other and returns \c true if they
- are considered equal in accordance with the provided \a options.
-
- The header names are always compared as case-insensitive, and values
- as case-sensitive. For example \e Accept and \e ACCEPT header names
- are considered equal, while values \e something and \e SOMETHING are not.
-*/
-bool QHttpHeaders::equals(const QHttpHeaders &other, CompareOptions options) const noexcept
-{
- return d == other.d || d->equals(*other.d, options);
-}
-
-/*!
Returns the header entries as a list of (name, value) pairs.
Header names are case-insensitive, and the returned names are lower-cased.
*/
diff --git a/src/network/access/qhttpheaders.h b/src/network/access/qhttpheaders.h
index df53cd6694..22a8b400fb 100644
--- a/src/network/access/qhttpheaders.h
+++ b/src/network/access/qhttpheaders.h
@@ -201,12 +201,6 @@ public:
};
Q_ENUM(WellKnownHeader)
- enum class CompareOption {
- OrderInsensitive = 0x01,
- OrderSensitive = 0x02,
- };
- Q_DECLARE_FLAGS(CompareOptions, CompareOption)
-
Q_NETWORK_EXPORT QHttpHeaders();
Q_NETWORK_EXPORT ~QHttpHeaders();
@@ -248,9 +242,6 @@ public:
Q_NETWORK_EXPORT void reserve(qsizetype size);
bool isEmpty() const noexcept { return size() == 0; }
- Q_NETWORK_EXPORT bool equals(const QHttpHeaders &other,
- CompareOptions options = CompareOption::OrderInsensitive) const noexcept;
-
Q_NETWORK_EXPORT static QHttpHeaders
fromListOfPairs(const QList<std::pair<QByteArray, QByteArray>> &headers);
Q_NETWORK_EXPORT static QHttpHeaders
@@ -269,8 +260,6 @@ private:
QExplicitlySharedDataPointer<QHttpHeadersPrivate> d;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QHttpHeaders::CompareOptions)
-
Q_DECLARE_SHARED(QHttpHeaders)
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkrequestfactory.cpp b/src/network/access/qnetworkrequestfactory.cpp
index 5c89821682..8a1ade8f78 100644
--- a/src/network/access/qnetworkrequestfactory.cpp
+++ b/src/network/access/qnetworkrequestfactory.cpp
@@ -122,35 +122,6 @@ QNetworkRequestFactory &QNetworkRequestFactory::operator=(const QNetworkRequestF
*/
/*!
- \fn bool QNetworkRequestFactory::operator==(const QNetworkRequestFactory &lhs,
- const QNetworkRequestFactory &rhs)
-
- Returns \c true if \a lhs is considered equal with \a rhs, meaning
- that all data in the factories match, otherwise returns \c false.
-
- \note The headers comparison is order-insensitive.
-
- \sa QNetworkRequestFactory::operator!=()
- */
-
-/*!
- \fn bool QNetworkRequestFactory::operator!=(const QNetworkRequestFactory &lhs,
- const QNetworkRequestFactory &rhs)
-
- Returns \c true if \a lhs is not considered equal with \a rhs.
-
- \sa QNetworkRequestFactory::operator==()
- */
-
-/*!
- \internal
- */
-bool comparesEqual(const QNetworkRequestFactory &lhs, const QNetworkRequestFactory &rhs) noexcept
-{
- return lhs.d == rhs.d || lhs.d->equals(*rhs.d);
-}
-
-/*!
Returns the base URL used for the individual requests.
The base URL may contain a path component. This path is used
@@ -594,22 +565,6 @@ QUrl QNetworkRequestFactoryPrivate::requestUrl(const QString *path,
return resultUrl;
}
-bool QNetworkRequestFactoryPrivate::equals(
- const QNetworkRequestFactoryPrivate &other) const noexcept
-{
- return
- transferTimeout == other.transferTimeout &&
-#if QT_CONFIG(ssl)
- sslConfig == other.sslConfig &&
-#endif
- baseUrl == other.baseUrl &&
- bearerToken == other.bearerToken &&
- userName == other.userName &&
- password == other.password &&
- headers.equals(other.headers) &&
- queryParameters == other.queryParameters;
-}
-
#ifndef QT_NO_DEBUG_STREAM
/*!
\fn QDebug QNetworkRequestFactory::operator<<(QDebug debug,
diff --git a/src/network/access/qnetworkrequestfactory.h b/src/network/access/qnetworkrequestfactory.h
index 931ae1e428..6eb439e03e 100644
--- a/src/network/access/qnetworkrequestfactory.h
+++ b/src/network/access/qnetworkrequestfactory.h
@@ -75,10 +75,6 @@ public:
Q_NETWORK_EXPORT void clearQueryParameters();
private:
- friend Q_NETWORK_EXPORT bool comparesEqual(const QNetworkRequestFactory &lhs,
- const QNetworkRequestFactory &rhs) noexcept;
- Q_DECLARE_EQUALITY_COMPARABLE(QNetworkRequestFactory)
-
#ifndef QT_NO_DEBUG_STREAM
friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkRequestFactory &reply);
#endif
diff --git a/src/network/access/qnetworkrequestfactory_p.h b/src/network/access/qnetworkrequestfactory_p.h
index c4fb33e8b2..4807e619f3 100644
--- a/src/network/access/qnetworkrequestfactory_p.h
+++ b/src/network/access/qnetworkrequestfactory_p.h
@@ -34,7 +34,6 @@ public:
~QNetworkRequestFactoryPrivate();
QNetworkRequest newRequest(const QUrl &url) const;
QUrl requestUrl(const QString *path = nullptr, const QUrlQuery *query = nullptr) const;
- bool equals(const QNetworkRequestFactoryPrivate &other) const noexcept;
#if QT_CONFIG(ssl)
QSslConfiguration sslConfig;