Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qnetworkrequest.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QNETWORKREQUEST_H
5#define QNETWORKREQUEST_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/QSharedDataPointer>
9#include <QtCore/QString>
10#include <QtCore/QUrl>
11#include <QtCore/QVariant>
12
14
18
20class Q_NETWORK_EXPORT QNetworkRequest
21{
22public:
30 ContentDispositionHeader, // added for QMultipartMessage
36 IfNoneMatchHeader
37 };
38 enum Attribute {
68
69 User = 1000,
70 UserMax = 32767
71 };
76 AlwaysCache
77 };
79 Automatic = 0,
80 Manual
81 };
82
83 enum Priority {
84 HighPriority = 1,
85 NormalPriority = 3,
86 LowPriority = 5
87 };
88
93 UserVerifiedRedirectPolicy
94 };
95
97 DefaultTransferTimeoutConstant = 30000
98 };
99
101 explicit QNetworkRequest(const QUrl &url);
104 QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; }
105 QNetworkRequest &operator=(const QNetworkRequest &other);
106
107 void swap(QNetworkRequest &other) noexcept { d.swap(other.d); }
108
109 bool operator==(const QNetworkRequest &other) const;
110 inline bool operator!=(const QNetworkRequest &other) const
111 { return !operator==(other); }
112
113 QUrl url() const;
114 void setUrl(const QUrl &url);
115
116 // "cooked" headers
117 QVariant header(KnownHeaders header) const;
118 void setHeader(KnownHeaders header, const QVariant &value);
119
120 // raw headers:
121 bool hasRawHeader(const QByteArray &headerName) const;
122 QList<QByteArray> rawHeaderList() const;
123 QByteArray rawHeader(const QByteArray &headerName) const;
125
126 // attributes
127 QVariant attribute(Attribute code, const QVariant &defaultValue = QVariant()) const;
128 void setAttribute(Attribute code, const QVariant &value);
129
130#ifndef QT_NO_SSL
131 QSslConfiguration sslConfiguration() const;
132 void setSslConfiguration(const QSslConfiguration &configuration);
133#endif
134
135 void setOriginatingObject(QObject *object);
136 QObject *originatingObject() const;
137
138 Priority priority() const;
139 void setPriority(Priority priority);
140
141 // HTTP redirect related
142 int maximumRedirectsAllowed() const;
143 void setMaximumRedirectsAllowed(int maximumRedirectsAllowed);
144
145 QString peerVerifyName() const;
146 void setPeerVerifyName(const QString &peerName);
147#if QT_CONFIG(http)
148 QHttp1Configuration http1Configuration() const;
149 void setHttp1Configuration(const QHttp1Configuration &configuration);
150
151 QHttp2Configuration http2Configuration() const;
152 void setHttp2Configuration(const QHttp2Configuration &configuration);
153
154 qint64 decompressedSafetyCheckThreshold() const;
155 void setDecompressedSafetyCheckThreshold(qint64 threshold);
156#endif // QT_CONFIG(http)
157
158#if QT_CONFIG(http) || defined (Q_OS_WASM)
159 int transferTimeout() const;
160 void setTransferTimeout(int timeout = DefaultTransferTimeoutConstant);
161#endif // QT_CONFIG(http) || defined (Q_OS_WASM)
162private:
165};
166
167Q_DECLARE_SHARED(QNetworkRequest)
168
170
173 QNetworkRequest__RedirectPolicy, Q_NETWORK_EXPORT)
174
175#endif
\inmodule QtCore
Definition qbytearray.h:57
The QHttp1Configuration class controls HTTP/1 parameters and settings.
The QHttp2Configuration class controls HTTP/2 parameters and settings.
Definition qlist.h:74
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
KnownHeaders
List of known header types that QNetworkRequest parses.
@ EmitAllUploadProgressSignalsAttribute
@ ConnectionCacheExpiryTimeoutSecondsAttribute
QNetworkRequest & operator=(QNetworkRequest &&other) noexcept
void swap(QNetworkRequest &other) noexcept
bool operator!=(const QNetworkRequest &other) const
Returns false if this object is not the same as other.
CacheLoadControl
Controls the caching mechanism of QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qshareddata.h:35
The QSslConfiguration class holds the configuration and state of an SSL connection.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:64
myinstance setPriority(MyClass::VeryHigh)
Combined button and popup list for selecting options.
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
@ User
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1367
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1355
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLbitfield GLuint64 timeout
[4]
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
request setUrl(QUrl("http://qt-project.org"))
long long qint64
Definition qtypes.h:55
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
this swap(other)
app setAttribute(Qt::AA_DontShowIconsInMenus)
textPart setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""))
imagePart setRawHeader("Content-ID", "my@content.id")
sslSocket setSslConfiguration(config)