Bill Yi | be1c96f | 2015-07-15 10:09:15 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ |
| 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 http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free |
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and |
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the |
| 22 | ** following information to ensure the GNU Lesser General Public License |
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and |
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
| 25 | ** |
| 26 | ** As a special exception, The Qt Company gives you certain additional |
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception |
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
| 29 | ** |
| 30 | ** $QT_END_LICENSE$ |
| 31 | ** |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | #ifndef QHTTPNETWORKREQUEST_H |
| 35 | #define QHTTPNETWORKREQUEST_H |
| 36 | |
| 37 | // |
| 38 | // W A R N I N G |
| 39 | // ------------- |
| 40 | // |
| 41 | // This file is not part of the Qt API. It exists for the convenience |
| 42 | // of the Network Access API. This header file may change from |
| 43 | // version to version without notice, or even be removed. |
| 44 | // |
| 45 | // We mean it. |
| 46 | // |
| 47 | #ifndef QT_NO_HTTP |
| 48 | |
| 49 | #include <private/qhttpnetworkheader_p.h> |
| 50 | #include <qmetatype.h> |
| 51 | |
| 52 | QT_BEGIN_NAMESPACE |
| 53 | |
| 54 | class QNonContiguousByteDevice; |
| 55 | |
| 56 | class QHttpNetworkRequestPrivate; |
| 57 | class Q_AUTOTEST_EXPORT QHttpNetworkRequest: public QHttpNetworkHeader |
| 58 | { |
| 59 | public: |
| 60 | enum Operation { |
| 61 | Options, |
| 62 | Get, |
| 63 | Head, |
| 64 | Post, |
| 65 | Put, |
| 66 | Delete, |
| 67 | Trace, |
| 68 | Connect, |
| 69 | Custom |
| 70 | }; |
| 71 | |
| 72 | enum Priority { |
| 73 | HighPriority, |
| 74 | NormalPriority, |
| 75 | LowPriority |
| 76 | }; |
| 77 | |
| 78 | explicit QHttpNetworkRequest(const QUrl &url = QUrl(), Operation operation = Get, Priority priority = NormalPriority); |
| 79 | QHttpNetworkRequest(const QHttpNetworkRequest &other); |
| 80 | virtual ~QHttpNetworkRequest(); |
| 81 | QHttpNetworkRequest &operator=(const QHttpNetworkRequest &other); |
| 82 | bool operator==(const QHttpNetworkRequest &other) const; |
| 83 | |
| 84 | QUrl url() const Q_DECL_OVERRIDE; |
| 85 | void setUrl(const QUrl &url) Q_DECL_OVERRIDE; |
| 86 | |
| 87 | int majorVersion() const Q_DECL_OVERRIDE; |
| 88 | int minorVersion() const Q_DECL_OVERRIDE; |
| 89 | |
| 90 | qint64 contentLength() const Q_DECL_OVERRIDE; |
| 91 | void setContentLength(qint64 length) Q_DECL_OVERRIDE; |
| 92 | |
| 93 | QList<QPair<QByteArray, QByteArray> > header() const Q_DECL_OVERRIDE; |
| 94 | QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const Q_DECL_OVERRIDE; |
| 95 | void setHeaderField(const QByteArray &name, const QByteArray &data) Q_DECL_OVERRIDE; |
| 96 | |
| 97 | Operation operation() const; |
| 98 | void setOperation(Operation operation); |
| 99 | |
| 100 | QByteArray customVerb() const; |
| 101 | void setCustomVerb(const QByteArray &customOperation); |
| 102 | |
| 103 | Priority priority() const; |
| 104 | void setPriority(Priority priority); |
| 105 | |
| 106 | bool isPipeliningAllowed() const; |
| 107 | void setPipeliningAllowed(bool b); |
| 108 | |
| 109 | bool isSPDYAllowed() const; |
| 110 | void setSPDYAllowed(bool b); |
| 111 | |
| 112 | bool withCredentials() const; |
| 113 | void setWithCredentials(bool b); |
| 114 | |
| 115 | bool isSsl() const; |
| 116 | void setSsl(bool); |
| 117 | |
| 118 | bool isPreConnect() const; |
| 119 | void setPreConnect(bool preConnect); |
| 120 | |
| 121 | void setUploadByteDevice(QNonContiguousByteDevice *bd); |
| 122 | QNonContiguousByteDevice* uploadByteDevice() const; |
| 123 | |
| 124 | QByteArray methodName() const; |
| 125 | QByteArray uri(bool throughProxy) const; |
| 126 | |
| 127 | private: |
| 128 | QSharedDataPointer<QHttpNetworkRequestPrivate> d; |
| 129 | friend class QHttpNetworkRequestPrivate; |
| 130 | friend class QHttpNetworkConnectionPrivate; |
| 131 | friend class QHttpNetworkConnectionChannel; |
| 132 | friend class QHttpProtocolHandler; |
| 133 | friend class QSpdyProtocolHandler; |
| 134 | }; |
| 135 | |
| 136 | class QHttpNetworkRequestPrivate : public QHttpNetworkHeaderPrivate |
| 137 | { |
| 138 | public: |
| 139 | QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, |
| 140 | QHttpNetworkRequest::Priority pri, const QUrl &newUrl = QUrl()); |
| 141 | QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other); |
| 142 | ~QHttpNetworkRequestPrivate(); |
| 143 | bool operator==(const QHttpNetworkRequestPrivate &other) const; |
| 144 | |
| 145 | static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy); |
| 146 | |
| 147 | QHttpNetworkRequest::Operation operation; |
| 148 | QByteArray customVerb; |
| 149 | QHttpNetworkRequest::Priority priority; |
| 150 | mutable QNonContiguousByteDevice* uploadByteDevice; |
| 151 | bool autoDecompress; |
| 152 | bool pipeliningAllowed; |
| 153 | bool spdyAllowed; |
| 154 | bool withCredentials; |
| 155 | bool ssl; |
| 156 | bool preConnect; |
| 157 | }; |
| 158 | |
| 159 | |
| 160 | QT_END_NAMESPACE |
| 161 | |
| 162 | Q_DECLARE_METATYPE(QHttpNetworkRequest) |
| 163 | |
| 164 | #endif // QT_NO_HTTP |
| 165 | |
| 166 | |
| 167 | #endif // QHTTPNETWORKREQUEST_H |