1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtNetwork module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QNETWORKREQUEST_H |
41 | #define QNETWORKREQUEST_H |
42 | |
43 | #include <QtNetwork/qtnetworkglobal.h> |
44 | #include <QtCore/QSharedDataPointer> |
45 | #include <QtCore/QString> |
46 | #include <QtCore/QUrl> |
47 | #include <QtCore/QVariant> |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | class QSslConfiguration; |
52 | class QHttp2Configuration; |
53 | |
54 | class QNetworkRequestPrivate; |
55 | class Q_NETWORK_EXPORT QNetworkRequest |
56 | { |
57 | public: |
58 | enum { |
59 | , |
60 | , |
61 | , |
62 | , |
63 | , |
64 | , |
65 | , // added for QMultipartMessage |
66 | , |
67 | , |
68 | , |
69 | , |
70 | , |
71 | |
72 | }; |
73 | enum Attribute { |
74 | HttpStatusCodeAttribute, |
75 | HttpReasonPhraseAttribute, |
76 | RedirectionTargetAttribute, |
77 | ConnectionEncryptedAttribute, |
78 | CacheLoadControlAttribute, |
79 | CacheSaveControlAttribute, |
80 | SourceIsFromCacheAttribute, |
81 | DoNotBufferUploadDataAttribute, |
82 | HttpPipeliningAllowedAttribute, |
83 | HttpPipeliningWasUsedAttribute, |
84 | CustomVerbAttribute, |
85 | CookieLoadControlAttribute, |
86 | AuthenticationReuseAttribute, |
87 | CookieSaveControlAttribute, |
88 | MaximumDownloadBufferSizeAttribute, // internal |
89 | DownloadBufferAttribute, // internal |
90 | SynchronousRequestAttribute, // internal |
91 | BackgroundRequestAttribute, |
92 | EmitAllUploadProgressSignalsAttribute, |
93 | Http2AllowedAttribute, |
94 | Http2WasUsedAttribute, |
95 | OriginalContentLengthAttribute, |
96 | RedirectPolicyAttribute, |
97 | Http2DirectAttribute, |
98 | ResourceTypeAttribute, // internal |
99 | AutoDeleteReplyOnFinishAttribute, |
100 | |
101 | User = 1000, |
102 | UserMax = 32767 |
103 | }; |
104 | enum CacheLoadControl { |
105 | AlwaysNetwork, |
106 | PreferNetwork, |
107 | PreferCache, |
108 | AlwaysCache |
109 | }; |
110 | enum LoadControl { |
111 | Automatic = 0, |
112 | Manual |
113 | }; |
114 | |
115 | enum Priority { |
116 | HighPriority = 1, |
117 | NormalPriority = 3, |
118 | LowPriority = 5 |
119 | }; |
120 | |
121 | enum RedirectPolicy { |
122 | ManualRedirectPolicy, |
123 | NoLessSafeRedirectPolicy, |
124 | SameOriginRedirectPolicy, |
125 | UserVerifiedRedirectPolicy |
126 | }; |
127 | |
128 | enum TransferTimeoutConstant { |
129 | DefaultTransferTimeoutConstant = 30000 |
130 | }; |
131 | |
132 | QNetworkRequest(); |
133 | explicit QNetworkRequest(const QUrl &url); |
134 | QNetworkRequest(const QNetworkRequest &other); |
135 | ~QNetworkRequest(); |
136 | QNetworkRequest &operator=(QNetworkRequest &&other) noexcept { swap(other); return *this; } |
137 | QNetworkRequest &operator=(const QNetworkRequest &other); |
138 | |
139 | void swap(QNetworkRequest &other) noexcept { qSwap(d, other.d); } |
140 | |
141 | bool operator==(const QNetworkRequest &other) const; |
142 | inline bool operator!=(const QNetworkRequest &other) const |
143 | { return !operator==(other); } |
144 | |
145 | QUrl url() const; |
146 | void setUrl(const QUrl &url); |
147 | |
148 | // "cooked" headers |
149 | QVariant (KnownHeaders ) const; |
150 | void (KnownHeaders , const QVariant &value); |
151 | |
152 | // raw headers: |
153 | bool (const QByteArray &) const; |
154 | QList<QByteArray> () const; |
155 | QByteArray (const QByteArray &) const; |
156 | void (const QByteArray &, const QByteArray &value); |
157 | |
158 | // attributes |
159 | QVariant attribute(Attribute code, const QVariant &defaultValue = QVariant()) const; |
160 | void setAttribute(Attribute code, const QVariant &value); |
161 | |
162 | #ifndef QT_NO_SSL |
163 | QSslConfiguration sslConfiguration() const; |
164 | void setSslConfiguration(const QSslConfiguration &configuration); |
165 | #endif |
166 | |
167 | void setOriginatingObject(QObject *object); |
168 | QObject *originatingObject() const; |
169 | |
170 | Priority priority() const; |
171 | void setPriority(Priority priority); |
172 | |
173 | // HTTP redirect related |
174 | int maximumRedirectsAllowed() const; |
175 | void setMaximumRedirectsAllowed(int maximumRedirectsAllowed); |
176 | |
177 | QString peerVerifyName() const; |
178 | void setPeerVerifyName(const QString &peerName); |
179 | #if QT_CONFIG(http) || defined(Q_CLANG_QDOC) |
180 | QHttp2Configuration http2Configuration() const; |
181 | void setHttp2Configuration(const QHttp2Configuration &configuration); |
182 | #endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC) |
183 | #if QT_CONFIG(http) || defined(Q_CLANG_QDOC) || defined (Q_OS_WASM) |
184 | int transferTimeout() const; |
185 | void setTransferTimeout(int timeout = DefaultTransferTimeoutConstant); |
186 | #endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC) || defined (Q_OS_WASM) |
187 | private: |
188 | QSharedDataPointer<QNetworkRequestPrivate> d; |
189 | friend class QNetworkRequestPrivate; |
190 | }; |
191 | |
192 | Q_DECLARE_SHARED(QNetworkRequest) |
193 | |
194 | QT_END_NAMESPACE |
195 | |
196 | Q_DECLARE_METATYPE(QNetworkRequest) |
197 | Q_DECLARE_METATYPE(QNetworkRequest::RedirectPolicy) |
198 | |
199 | #endif |
200 | |