1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtNetwork module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QNETWORKREPLY_H
|
---|
43 | #define QNETWORKREPLY_H
|
---|
44 |
|
---|
45 | #include <QtCore/QIODevice>
|
---|
46 | #include <QtCore/QString>
|
---|
47 | #include <QtCore/QVariant>
|
---|
48 |
|
---|
49 | #include <QtNetwork/QNetworkRequest>
|
---|
50 | #include <QtNetwork/QNetworkAccessManager>
|
---|
51 |
|
---|
52 | QT_BEGIN_HEADER
|
---|
53 |
|
---|
54 | QT_BEGIN_NAMESPACE
|
---|
55 |
|
---|
56 | QT_MODULE(Network)
|
---|
57 |
|
---|
58 | class QUrl;
|
---|
59 | class QVariant;
|
---|
60 | class QAuthenticator;
|
---|
61 | class QSslConfiguration;
|
---|
62 | class QSslError;
|
---|
63 |
|
---|
64 | class QNetworkReplyPrivate;
|
---|
65 | class Q_NETWORK_EXPORT QNetworkReply: public QIODevice
|
---|
66 | {
|
---|
67 | Q_OBJECT
|
---|
68 | Q_ENUMS(NetworkError)
|
---|
69 | public:
|
---|
70 | enum NetworkError {
|
---|
71 | NoError = 0,
|
---|
72 |
|
---|
73 | // network layer errors [relating to the destination server] (1-99):
|
---|
74 | ConnectionRefusedError = 1,
|
---|
75 | RemoteHostClosedError,
|
---|
76 | HostNotFoundError,
|
---|
77 | TimeoutError,
|
---|
78 | OperationCanceledError,
|
---|
79 | SslHandshakeFailedError,
|
---|
80 | TemporaryNetworkFailureError,
|
---|
81 | UnknownNetworkError = 99,
|
---|
82 |
|
---|
83 | // proxy errors (101-199):
|
---|
84 | ProxyConnectionRefusedError = 101,
|
---|
85 | ProxyConnectionClosedError,
|
---|
86 | ProxyNotFoundError,
|
---|
87 | ProxyTimeoutError,
|
---|
88 | ProxyAuthenticationRequiredError,
|
---|
89 | UnknownProxyError = 199,
|
---|
90 |
|
---|
91 | // content errors (201-299):
|
---|
92 | ContentAccessDenied = 201,
|
---|
93 | ContentOperationNotPermittedError,
|
---|
94 | ContentNotFoundError,
|
---|
95 | AuthenticationRequiredError,
|
---|
96 | ContentReSendError,
|
---|
97 | UnknownContentError = 299,
|
---|
98 |
|
---|
99 | // protocol errors
|
---|
100 | ProtocolUnknownError = 301,
|
---|
101 | ProtocolInvalidOperationError,
|
---|
102 | ProtocolFailure = 399
|
---|
103 | };
|
---|
104 |
|
---|
105 | ~QNetworkReply();
|
---|
106 | virtual void abort() = 0;
|
---|
107 |
|
---|
108 | // reimplemented from QIODevice
|
---|
109 | virtual void close();
|
---|
110 | virtual bool isSequential() const;
|
---|
111 |
|
---|
112 | // like QAbstractSocket:
|
---|
113 | qint64 readBufferSize() const;
|
---|
114 | virtual void setReadBufferSize(qint64 size);
|
---|
115 |
|
---|
116 | QNetworkAccessManager *manager() const;
|
---|
117 | QNetworkAccessManager::Operation operation() const;
|
---|
118 | QNetworkRequest request() const;
|
---|
119 | NetworkError error() const;
|
---|
120 | bool isFinished() const;
|
---|
121 | bool isRunning() const;
|
---|
122 | QUrl url() const;
|
---|
123 |
|
---|
124 | // "cooked" headers
|
---|
125 | QVariant header(QNetworkRequest::KnownHeaders header) const;
|
---|
126 |
|
---|
127 | // raw headers:
|
---|
128 | bool hasRawHeader(const QByteArray &headerName) const;
|
---|
129 | QList<QByteArray> rawHeaderList() const;
|
---|
130 | QByteArray rawHeader(const QByteArray &headerName) const;
|
---|
131 |
|
---|
132 | typedef QPair<QByteArray, QByteArray> RawHeaderPair;
|
---|
133 | const QList<RawHeaderPair>& rawHeaderPairs() const;
|
---|
134 |
|
---|
135 | // attributes
|
---|
136 | QVariant attribute(QNetworkRequest::Attribute code) const;
|
---|
137 |
|
---|
138 | #ifndef QT_NO_OPENSSL
|
---|
139 | QSslConfiguration sslConfiguration() const;
|
---|
140 | void setSslConfiguration(const QSslConfiguration &configuration);
|
---|
141 | void ignoreSslErrors(const QList<QSslError> &errors);
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | public Q_SLOTS:
|
---|
145 | virtual void ignoreSslErrors();
|
---|
146 |
|
---|
147 | Q_SIGNALS:
|
---|
148 | void metaDataChanged();
|
---|
149 | void finished();
|
---|
150 | void error(QNetworkReply::NetworkError);
|
---|
151 | #ifndef QT_NO_OPENSSL
|
---|
152 | void sslErrors(const QList<QSslError> &errors);
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
|
---|
156 | void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
---|
157 |
|
---|
158 | protected:
|
---|
159 | QNetworkReply(QObject *parent = 0);
|
---|
160 | QNetworkReply(QNetworkReplyPrivate &dd, QObject *parent);
|
---|
161 | virtual qint64 writeData(const char *data, qint64 len);
|
---|
162 |
|
---|
163 | void setOperation(QNetworkAccessManager::Operation operation);
|
---|
164 | void setRequest(const QNetworkRequest &request);
|
---|
165 | void setError(NetworkError errorCode, const QString &errorString);
|
---|
166 | void setUrl(const QUrl &url);
|
---|
167 | void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
|
---|
168 | void setRawHeader(const QByteArray &headerName, const QByteArray &value);
|
---|
169 | void setAttribute(QNetworkRequest::Attribute code, const QVariant &value);
|
---|
170 |
|
---|
171 | private:
|
---|
172 | Q_DECLARE_PRIVATE(QNetworkReply)
|
---|
173 | };
|
---|
174 |
|
---|
175 | QT_END_NAMESPACE
|
---|
176 |
|
---|
177 | QT_END_HEADER
|
---|
178 |
|
---|
179 | #endif
|
---|