Qt 4.8
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 
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();
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);
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:
174 };
175 
177 
179 
180 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition: qiodevice.cpp:590
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
#define error(msg)
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
Definition: qnetworkreply.h:65
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
NetworkError
Indicates all possible error conditions found during the processing of the request.
Definition: qnetworkreply.h:70
Operation
Indicates the operation this reply is processing.
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
KnownHeaders
List of known header types that QNetworkRequest parses.
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
QPair< QByteArray, QByteArray > RawHeaderPair
RawHeaderPair is a QPair<QByteArray, QByteArray> where the first QByteArray is the header name and th...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const char * data(const QByteArray &arr)
__int64 qint64
Definition: qglobal.h:942
The QNetworkAccessManager class allows the application to send network requests and receive replies...
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QAuthenticator class provides an authentication object.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
Definition: qiodevice.cpp:454
Attribute
Attribute codes for the QNetworkRequest and QNetworkReply.
#define Q_NETWORK_EXPORT
Definition: qglobal.h:1452
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
The QSslConfiguration class holds the configuration and state of an SSL connection.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QSslError class provides an SSL error.
Definition: qsslerror.h:58
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137