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 QHTTPNETWORKREQUEST_H 41 #define QHTTPNETWORKREQUEST_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists for the convenience 48 // of the Network Access API. This header file may change from 49 // version to version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 #include <QtNetwork/private/qtnetworkglobal_p.h> 54 55 #include <private/qhttpnetworkheader_p.h> 56 #include <QtNetwork/qnetworkrequest.h> 57 #include <qmetatype.h> 58 59 QT_REQUIRE_CONFIG(http); 60 61 QT_BEGIN_NAMESPACE 62 63 class QNonContiguousByteDevice; 64 65 class QHttpNetworkRequestPrivate; 66 class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader 67 { 68 public: 69 enum Operation { 70 Options, 71 Get, 72 Head, 73 Post, 74 Put, 75 Delete, 76 Trace, 77 Connect, 78 Custom 79 }; 80 81 enum Priority { 82 HighPriority, 83 NormalPriority, 84 LowPriority 85 }; 86 87 explicit QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority); 88 QHttpNetworkRequest(const QHttpNetworkRequest &other); 89 virtual ~QHttpNetworkRequest(); 90 QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other); 91 bool operator==(const QHttpNetworkRequest &other) const; 92 93 QUrl url() const override; 94 void setUrl(const QUrl &url) override; 95 96 int majorVersion() const override; 97 int minorVersion() const override; 98 99 qint64 contentLength() const override; 100 void setContentLength(qint64 length) override; 101 102 QList<QPair<QByteArray, QByteArray> > header() const override; 103 QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const override; 104 void setHeaderField(const QByteArray &name, const QByteArray &data) override; 105 void prependHeaderField(const QByteArray &name, const QByteArray &data); 106 void clearHeaders(); 107 108 Operation operation() const; 109 void setOperation(Operation operation); 110 111 QByteArray customVerb() const; 112 void setCustomVerb(const QByteArray &customOperation); 113 114 Priority priority() const; 115 void setPriority(Priority priority); 116 117 bool isPipeliningAllowed() const; 118 void setPipeliningAllowed(bool b); 119 120 bool isSPDYAllowed() const; 121 void setSPDYAllowed(bool b); 122 123 bool isHTTP2Allowed() const; 124 void setHTTP2Allowed(bool b); 125 126 bool isHTTP2Direct() const; 127 void setHTTP2Direct(bool b); 128 129 bool withCredentials() const; 130 void setWithCredentials(bool b); 131 132 bool isSsl() const; 133 void setSsl(bool); 134 135 bool isPreConnect() const; 136 void setPreConnect(bool preConnect); 137 138 bool isFollowRedirects() const; 139 void setRedirectPolicy(QNetworkRequest::RedirectPolicy policy); 140 QNetworkRequest::RedirectPolicy redirectPolicy() const; 141 142 int redirectCount() const; 143 void setRedirectCount(int count); 144 145 void setUploadByteDevice(QNonContiguousByteDevice *bd); 146 QNonContiguousByteDevice* uploadByteDevice() const; 147 148 QByteArray methodName() const; 149 QByteArray uri(bool throughProxy) const; 150 151 QString peerVerifyName() const; 152 void setPeerVerifyName(const QString &peerName); 153 private: 154 QSharedDataPointer<QHttpNetworkRequestPrivate> d; 155 friend class QHttpNetworkRequestPrivate; 156 friend class QHttpNetworkConnectionPrivate; 157 friend class QHttpNetworkConnectionChannel; 158 friend class QHttpProtocolHandler; 159 friend class QHttp2ProtocolHandler; 160 friend class QSpdyProtocolHandler; 161 }; 162 163 class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate 164 { 165 public: 166 QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, 167 QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl()); 168 QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other); 169 ~QHttpNetworkRequestPrivate(); 170 bool operator==(const QHttpNetworkRequestPrivate &other) const; 171 172 static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy); 173 174 QHttpNetworkRequest::Operation operation; 175 QByteArray customVerb; 176 QHttpNetworkRequest::Priority priority; 177 mutable QNonContiguousByteDevice* uploadByteDevice; 178 bool autoDecompress; 179 bool pipeliningAllowed; 180 bool spdyAllowed; 181 bool http2Allowed; 182 bool http2Direct; 183 bool withCredentials; 184 bool ssl; 185 bool preConnect; 186 int redirectCount; 187 QNetworkRequest::RedirectPolicy redirectPolicy; 188 QString peerVerifyName; 189 }; 190 191 192 QT_END_NAMESPACE 193 194 Q_DECLARE_METATYPE(QHttpNetworkRequest) 195 196 #endif // QHTTPNETWORKREQUEST_H 197