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 QHTTPNETWORKREQUEST_H |
5 | #define QHTTPNETWORKREQUEST_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of the Network Access API. This header file may change from |
13 | // version to version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | #include <QtNetwork/private/qtnetworkglobal_p.h> |
18 | |
19 | #include <private/qhttpnetworkheader_p.h> |
20 | #include <QtNetwork/qnetworkrequest.h> |
21 | #include <qmetatype.h> |
22 | |
23 | #ifndef Q_OS_WASM |
24 | QT_REQUIRE_CONFIG(http); |
25 | #endif |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QNonContiguousByteDevice; |
30 | |
31 | class QHttpNetworkRequestPrivate; |
32 | class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader |
33 | { |
34 | public: |
35 | enum Operation { |
36 | Options, |
37 | Get, |
38 | Head, |
39 | Post, |
40 | Put, |
41 | Delete, |
42 | Trace, |
43 | Connect, |
44 | Custom |
45 | }; |
46 | |
47 | enum Priority { |
48 | HighPriority, |
49 | NormalPriority, |
50 | LowPriority |
51 | }; |
52 | |
53 | explicit QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority); |
54 | QHttpNetworkRequest(const QHttpNetworkRequest &other); |
55 | ~QHttpNetworkRequest() override; |
56 | QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other); |
57 | bool operator==(const QHttpNetworkRequest &other) const; |
58 | |
59 | QUrl url() const override; |
60 | void setUrl(const QUrl &url) override; |
61 | |
62 | int majorVersion() const override; |
63 | int minorVersion() const override; |
64 | |
65 | qint64 contentLength() const override; |
66 | void setContentLength(qint64 length) override; |
67 | |
68 | QHttpHeaders () const override; |
69 | QByteArray (QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const override; |
70 | void (const QByteArray &name, const QByteArray &data) override; |
71 | void (const QByteArray &name, const QByteArray &data); |
72 | void (); |
73 | |
74 | Operation operation() const; |
75 | void setOperation(Operation operation); |
76 | |
77 | QByteArray customVerb() const; |
78 | void setCustomVerb(const QByteArray &customOperation); |
79 | |
80 | Priority priority() const; |
81 | void setPriority(Priority priority); |
82 | |
83 | bool isPipeliningAllowed() const; |
84 | void setPipeliningAllowed(bool b); |
85 | |
86 | bool isHTTP2Allowed() const; |
87 | void setHTTP2Allowed(bool b); |
88 | |
89 | bool isHTTP2Direct() const; |
90 | void setHTTP2Direct(bool b); |
91 | |
92 | bool isH2cAllowed() const; |
93 | void setH2cAllowed(bool b); |
94 | |
95 | bool withCredentials() const; |
96 | void setWithCredentials(bool b); |
97 | |
98 | bool isSsl() const; |
99 | void setSsl(bool); |
100 | |
101 | bool isPreConnect() const; |
102 | void setPreConnect(bool preConnect); |
103 | |
104 | bool isFollowRedirects() const; |
105 | void setRedirectPolicy(QNetworkRequest::RedirectPolicy policy); |
106 | QNetworkRequest::RedirectPolicy redirectPolicy() const; |
107 | |
108 | int redirectCount() const; |
109 | void setRedirectCount(int count); |
110 | |
111 | void setUploadByteDevice(QNonContiguousByteDevice *bd); |
112 | QNonContiguousByteDevice* uploadByteDevice() const; |
113 | |
114 | QByteArray methodName() const; |
115 | QByteArray uri(bool throughProxy) const; |
116 | |
117 | QString peerVerifyName() const; |
118 | void setPeerVerifyName(const QString &peerName); |
119 | |
120 | QString fullLocalServerName() const; |
121 | void setFullLocalServerName(const QString &fullServerName); |
122 | |
123 | private: |
124 | QSharedDataPointer<QHttpNetworkRequestPrivate> d; |
125 | friend class QHttpNetworkRequestPrivate; |
126 | friend class QHttpNetworkConnectionPrivate; |
127 | friend class QHttpNetworkConnectionChannel; |
128 | friend class QHttpProtocolHandler; |
129 | friend class QHttp2ProtocolHandler; |
130 | friend class QSpdyProtocolHandler; |
131 | }; |
132 | |
133 | class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate |
134 | { |
135 | public: |
136 | QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, |
137 | QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl()); |
138 | QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other); |
139 | ~QHttpNetworkRequestPrivate(); |
140 | bool operator==(const QHttpNetworkRequestPrivate &other) const; |
141 | |
142 | static QByteArray (const QHttpNetworkRequest &request, bool throughProxy); |
143 | |
144 | QHttpNetworkRequest::Operation operation; |
145 | QByteArray customVerb; |
146 | QString fullLocalServerName; // for local sockets |
147 | QHttpNetworkRequest::Priority priority; |
148 | mutable QNonContiguousByteDevice* uploadByteDevice; |
149 | bool autoDecompress; |
150 | bool pipeliningAllowed; |
151 | bool http2Allowed; |
152 | bool http2Direct; |
153 | bool h2cAllowed = false; |
154 | bool withCredentials; |
155 | bool ssl = false; |
156 | bool preConnect; |
157 | bool needResendWithCredentials = false; |
158 | int redirectCount; |
159 | QNetworkRequest::RedirectPolicy redirectPolicy; |
160 | QString peerVerifyName; |
161 | }; |
162 | |
163 | |
164 | QT_END_NAMESPACE |
165 | |
166 | QT_DECL_METATYPE_EXTERN(QHttpNetworkRequest, Q_AUTOTEST_EXPORT) |
167 | |
168 | #endif // QHTTPNETWORKREQUEST_H |
169 | |