QtNetwork/qnetworkreply.h Source File

qnetworkreply.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 
53 
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
69 public:
70  enum NetworkError {
71  NoError = 0,
72 
73  // network layer errors [relating to the destination server] (1-99):
74  ConnectionRefusedError = 1,
81  UnknownNetworkError = 99,
82 
83  // proxy errors (101-199):
84  ProxyConnectionRefusedError = 101,
89  UnknownProxyError = 199,
90 
91  // content errors (201-299):
92  ContentAccessDenied = 201,
97  UnknownContentError = 299,
98 
99  // protocol errors
100  ProtocolUnknownError = 301,
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 
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 setFinished(bool);
167  void setUrl(const QUrl &url);
168  void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value);
169  void setRawHeader(const QByteArray &headerName, const QByteArray &value);
170  void setAttribute(QNetworkRequest::Attribute code, const QVariant &value);
171 
172 private:
173  Q_DECLARE_PRIVATE(QNetworkReply)
174 };
175 
177 
179 
180 #endif
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
long long qint64
Definition: qglobal.h:947
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
#define Q_OBJECT
Definition: qobjectdefs.h:157
GLsizei const GLfloat * value
Definition: GLee.h:1742
Definition: qurl.h:61
GLXFBConfig int attribute
Definition: GLee.h:10233
GLenum GLsizei len
Definition: GLee.h:2695
#define QT_END_HEADER
Definition: qglobal.h:142
GLsizeiptr size
Definition: GLee.h:1561
QPair< QByteArray, QByteArray > RawHeaderPair