diff options
Diffstat (limited to 'src/network/access/qnetworkrequest.h')
-rw-r--r-- | src/network/access/qnetworkrequest.h | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h index a9abcf8c49..e281c74834 100644 --- a/src/network/access/qnetworkrequest.h +++ b/src/network/access/qnetworkrequest.h @@ -5,6 +5,7 @@ #define QNETWORKREQUEST_H #include <QtNetwork/qtnetworkglobal.h> +#include <QtNetwork/qhttpheaders.h> #include <QtCore/QSharedDataPointer> #include <QtCore/QString> #include <QtCore/QUrl> @@ -14,10 +15,12 @@ QT_BEGIN_NAMESPACE class QSslConfiguration; class QHttp2Configuration; +class QHttp1Configuration; class QNetworkRequestPrivate; class Q_NETWORK_EXPORT QNetworkRequest { + Q_GADGET public: enum KnownHeaders { ContentTypeHeader, @@ -32,8 +35,11 @@ public: IfModifiedSinceHeader, ETagHeader, IfMatchHeader, - IfNoneMatchHeader + IfNoneMatchHeader, + NumKnownHeaders }; + Q_ENUM(KnownHeaders) + enum Attribute { HttpStatusCodeAttribute, HttpReasonPhraseAttribute, @@ -63,6 +69,7 @@ public: AutoDeleteReplyOnFinishAttribute, ConnectionCacheExpiryTimeoutSecondsAttribute, Http2CleartextAllowedAttribute, + UseCredentialsAttribute, User = 1000, UserMax = 32767 @@ -95,6 +102,9 @@ public: DefaultTransferTimeoutConstant = 30000 }; + static constexpr auto DefaultTransferTimeout = + std::chrono::milliseconds(DefaultTransferTimeoutConstant); + QNetworkRequest(); explicit QNetworkRequest(const QUrl &url); QNetworkRequest(const QNetworkRequest &other); @@ -111,14 +121,24 @@ public: QUrl url() const; void setUrl(const QUrl &url); + QHttpHeaders headers() const; + void setHeaders(const QHttpHeaders &newHeaders); + void setHeaders(QHttpHeaders &&newHeaders); + // "cooked" headers QVariant header(KnownHeaders header) const; 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(QAnyStringView headerName) const; QList<QByteArray> rawHeaderList() const; +#if QT_NETWORK_REMOVED_SINCE(6, 7) QByteArray rawHeader(const QByteArray &headerName) const; +#endif + QByteArray rawHeader(QAnyStringView headerName) const; void setRawHeader(const QByteArray &headerName, const QByteArray &value); // attributes @@ -142,18 +162,26 @@ public: QString peerVerifyName() const; void setPeerVerifyName(const QString &peerName); -#if QT_CONFIG(http) || defined(Q_CLANG_QDOC) +#if QT_CONFIG(http) + QHttp1Configuration http1Configuration() const; + void setHttp1Configuration(const QHttp1Configuration &configuration); + QHttp2Configuration http2Configuration() const; void setHttp2Configuration(const QHttp2Configuration &configuration); qint64 decompressedSafetyCheckThreshold() const; void setDecompressedSafetyCheckThreshold(qint64 threshold); -#endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC) +#endif // QT_CONFIG(http) -#if QT_CONFIG(http) || defined(Q_CLANG_QDOC) || defined (Q_OS_WASM) +#if QT_CONFIG(http) || defined (Q_OS_WASM) + QT_NETWORK_INLINE_SINCE(6, 8) int transferTimeout() const; - void setTransferTimeout(int timeout = DefaultTransferTimeoutConstant); -#endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC) || defined (Q_OS_WASM) + QT_NETWORK_INLINE_SINCE(6, 8) + void setTransferTimeout(int timeout); + + std::chrono::milliseconds transferTimeoutAsDuration() const; + void setTransferTimeout(std::chrono::milliseconds duration = DefaultTransferTimeout); +#endif // QT_CONFIG(http) || defined (Q_OS_WASM) private: QSharedDataPointer<QNetworkRequestPrivate> d; friend class QNetworkRequestPrivate; @@ -161,6 +189,20 @@ private: Q_DECLARE_SHARED(QNetworkRequest) +#if QT_NETWORK_INLINE_IMPL_SINCE(6, 8) +#if QT_CONFIG(http) || defined (Q_OS_WASM) +int QNetworkRequest::transferTimeout() const +{ + return int(transferTimeoutAsDuration().count()); +} + +void QNetworkRequest::setTransferTimeout(int timeout) +{ + setTransferTimeout(std::chrono::milliseconds(timeout)); +} +#endif // QT_CONFIG(http) || defined (Q_OS_WASM) +#endif // INLINE_SINCE 6.8 + QT_END_NAMESPACE QT_DECL_METATYPE_EXTERN(QNetworkRequest, Q_NETWORK_EXPORT) |