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 | virtual ~QHttpNetworkRequest(); |
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 | QList<QPair<QByteArray, QByteArray> > () const override; |
69 | QByteArray (const QByteArray &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 | private: |
121 | QSharedDataPointer<QHttpNetworkRequestPrivate> d; |
122 | friend class QHttpNetworkRequestPrivate; |
123 | friend class QHttpNetworkConnectionPrivate; |
124 | friend class QHttpNetworkConnectionChannel; |
125 | friend class QHttpProtocolHandler; |
126 | friend class QHttp2ProtocolHandler; |
127 | friend class QSpdyProtocolHandler; |
128 | }; |
129 | |
130 | class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate |
131 | { |
132 | public: |
133 | QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, |
134 | QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl()); |
135 | QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other); |
136 | ~QHttpNetworkRequestPrivate(); |
137 | bool operator==(const QHttpNetworkRequestPrivate &other) const; |
138 | |
139 | static QByteArray (const QHttpNetworkRequest &request, bool throughProxy); |
140 | |
141 | QHttpNetworkRequest::Operation operation; |
142 | QByteArray customVerb; |
143 | QHttpNetworkRequest::Priority priority; |
144 | mutable QNonContiguousByteDevice* uploadByteDevice; |
145 | bool autoDecompress; |
146 | bool pipeliningAllowed; |
147 | bool http2Allowed; |
148 | bool http2Direct; |
149 | bool h2cAllowed = false; |
150 | bool withCredentials; |
151 | bool ssl; |
152 | bool preConnect; |
153 | bool needResendWithCredentials = false; |
154 | int redirectCount; |
155 | QNetworkRequest::RedirectPolicy redirectPolicy; |
156 | QString peerVerifyName; |
157 | }; |
158 | |
159 | |
160 | QT_END_NAMESPACE |
161 | |
162 | QT_DECL_METATYPE_EXTERN(QHttpNetworkRequest, Q_AUTOTEST_EXPORT) |
163 | |
164 | #endif // QHTTPNETWORKREQUEST_H |
165 | |