Qt 4.8
qnetworkaccesshttpbackend_p.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 QNETWORKACCESSHTTPBACKEND_P_H
43 #define QNETWORKACCESSHTTPBACKEND_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of the Network Access API. This header file may change from
51 // version to version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
58 #include "qnetworkrequest.h"
59 #include "qnetworkreply.h"
60 #include "qabstractsocket.h"
61 
62 #include "QtCore/qpointer.h"
63 #include "QtCore/qdatetime.h"
64 #include "QtCore/qsharedpointer.h"
65 #include "qatomic.h"
66 
67 #ifndef QT_NO_HTTP
68 
70 
72 
73 class QNetworkAccessHttpBackendIODevice;
74 
76 {
77  Q_OBJECT
78 public:
81 
82  virtual void open();
83  virtual void closeDownstreamChannel();
84 
85  virtual void downstreamReadyWrite();
86  virtual void setDownstreamLimited(bool b);
87  virtual void setReadBufferSize(qint64 size);
88  virtual void emitReadBufferFreed(qint64 size);
89 
90  virtual void copyFinished(QIODevice *);
91 #ifndef QT_NO_OPENSSL
92  virtual void ignoreSslErrors();
93  virtual void ignoreSslErrors(const QList<QSslError> &errors);
94 
95  virtual void fetchSslConfiguration(QSslConfiguration &configuration) const;
96  virtual void setSslConfiguration(const QSslConfiguration &configuration);
97 #endif
99 
100  // we return true since HTTP needs to send PUT/POST data again after having authenticated
101  bool needsResetableUploadData() { return true; }
102 
103  bool canResume() const;
104  void setResumeOffset(quint64 offset);
105 
106 signals:
107  // To HTTP thread:
108  void startHttpRequest();
109  void abortHttpRequest();
110  void readBufferSizeChanged(qint64 size);
111  void readBufferFreed(qint64 size);
112 
114 
115  void haveUploadData(QByteArray dataArray, bool dataAtEnd, qint64 dataSize);
116 private slots:
117  // From HTTP thread:
119  void replyFinished();
124 #ifndef QT_NO_OPENSSL
125  void replySslErrors(const QList<QSslError> &, bool *, QList<QSslError> *);
127 #endif
128 
129  // From QNonContiguousByteDeviceThreadForwardImpl in HTTP thread:
130  void resetUploadDataSlot(bool *r);
133 
134  bool sendCacheContents(const QNetworkCacheMetaData &metaData);
135 
136 private:
137  QHttpNetworkRequest httpRequest; // There is also a copy in the HTTP thread
140  // Will be increased by HTTP thread:
146 
147 #ifndef QT_NO_OPENSSL
151 #endif
152 
154 
155  bool loadFromCacheIfAllowed(QHttpNetworkRequest &httpRequest);
156  void invalidateCache();
157  void postRequest();
158  void readFromHttp();
159  void checkForRedirect(const int statusCode);
160 };
161 
163 {
164 public:
166  const QNetworkRequest &request) const;
167 };
168 
170 
171 #endif // QT_NO_HTTP
172 
173 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
NetworkError
Indicates all possible error conditions found during the processing of the request.
Definition: qnetworkreply.h:70
void readBufferFreed(qint64 size)
Operation
Indicates the operation this reply is processing.
bool loadFromCacheIfAllowed(QHttpNetworkRequest &httpRequest)
void httpError(QNetworkReply::NetworkError error, const QString &errorString)
The QString class provides a Unicode character string.
Definition: qstring.h:83
void checkForRedirect(const int statusCode)
void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth)
QSharedPointer< QAtomicInt > pendingDownloadDataEmissions
void haveUploadData(QByteArray dataArray, bool dataAtEnd, qint64 dataSize)
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
virtual void copyFinished(QIODevice *)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QNetworkCacheMetaData fetchCacheMetaData(const QNetworkCacheMetaData &metaData) const
unsigned __int64 quint64
Definition: qglobal.h:943
bool sendCacheContents(const QNetworkCacheMetaData &metaData)
__int64 qint64
Definition: qglobal.h:942
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QAuthenticator class provides an authentication object.
void readBufferSizeChanged(qint64 size)
virtual void setReadBufferSize(qint64 size)
void error(QNetworkReply::NetworkError code, const QString &errorString)
void replySslConfigurationChanged(const QSslConfiguration &)
QNetworkRequest request() const
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
void replyDownloadProgressSlot(qint64, qint64)
The QSslConfiguration class holds the configuration and state of an SSL connection.
void replyDownloadMetaData(QList< QPair< QByteArray, QByteArray > >, int, QString, bool, QSharedPointer< char >, qint64)
QSharedPointer< QAtomicInt > pendingDownloadProgressEmissions
#define slots
Definition: qobjectdefs.h:68
void replySslErrors(const QList< QSslError > &, bool *, QList< QSslError > *)
#define signals
Definition: qobjectdefs.h:69
virtual void setSslConfiguration(const QSslConfiguration &configuration)
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
virtual void fetchSslConfiguration(QSslConfiguration &configuration) const
The QNetworkCacheMetaData class provides cache information.
virtual void emitReadBufferFreed(qint64 size)