Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qhttpnetworkreply_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QHTTPNETWORKREPLY_H
5#define QHTTPNETWORKREPLY_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19
20#include <qplatformdefs.h>
21
22#include <QtNetwork/qtcpsocket.h>
23// it's safe to include these even if SSL support is not enabled
24#include <QtNetwork/qsslsocket.h>
25#include <QtNetwork/qsslerror.h>
26
27#include <QtNetwork/qnetworkrequest.h>
28#include <QtNetwork/qnetworkreply.h>
29#include <qbuffer.h>
30
31#include <private/qobject_p.h>
32#include <private/qhttpnetworkheader_p.h>
33#include <private/qhttpnetworkrequest_p.h>
34#include <private/qauthenticator_p.h>
35#include <private/qringbuffer_p.h>
36#include <private/qbytedata_p.h>
37
38#ifndef QT_NO_NETWORKPROXY
40#endif
42
43#include <private/qdecompresshelper_p.h>
44#include <QtNetwork/qhttpheaders.h>
45
46#include <QtCore/qpointer.h>
47
49
51
57class Q_NETWORK_EXPORT QHttpNetworkReply : public QObject, public QHttpNetworkHeader
58{
60public:
61
62 explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = nullptr);
63 virtual ~QHttpNetworkReply();
64
65 QUrl url() const override;
66 void setUrl(const QUrl &url) override;
67
68 int majorVersion() const override;
69 int minorVersion() const override;
70 void setMajorVersion(int version);
71 void setMinorVersion(int version);
72
73 qint64 contentLength() const override;
74 void setContentLength(qint64 length) override;
75
76 QHttpHeaders header() const override;
77 QByteArray headerField(QByteArrayView name, const QByteArray &defaultValue = QByteArray()) const override;
78 void setHeaderField(const QByteArray &name, const QByteArray &data) override;
79 void appendHeaderField(const QByteArray &name, const QByteArray &data);
80 void parseHeader(QByteArrayView header); // used for testing
81
83 void setRequest(const QHttpNetworkRequest &request);
84
85 int statusCode() const;
86 void setStatusCode(int code);
87
88 QString errorString() const;
89 void setErrorString(const QString &error);
90
91 QNetworkReply::NetworkError errorCode() const;
92
93 QString reasonPhrase() const;
94 void setReasonPhrase(const QString &reason);
95
96 qint64 bytesAvailable() const;
97 qint64 bytesAvailableNextBlock() const;
98 bool readAnyAvailable() const;
99 QByteArray readAny();
100 QByteArray readAll();
101 QByteArray read(qint64 amount);
102 qint64 sizeNextBlock();
103 void setDownstreamLimited(bool t);
104 void setReadBufferSize(qint64 size);
105
106 bool supportsUserProvidedDownloadBuffer();
107 void setUserProvidedDownloadBuffer(char*);
108 char* userProvidedDownloadBuffer();
109
110 void abort();
111
112 bool isAborted() const;
113 bool isFinished() const;
114
115 bool isPipeliningUsed() const;
116 bool isHttp2Used() const;
117 void setHttp2WasUsed(bool h2Used);
118 qint64 removedContentLength() const;
119
120 bool isRedirecting() const;
121
123
124 QUrl redirectUrl() const;
125 void setRedirectUrl(const QUrl &url);
126
127 static bool isHttpRedirect(int statusCode);
128
129 bool isCompressed() const;
130
131#ifndef QT_NO_SSL
132 QSslConfiguration sslConfiguration() const;
134 void ignoreSslErrors();
135 void ignoreSslErrors(const QList<QSslError> &errors);
136
138 void encrypted();
139 void sslErrors(const QList<QSslError> &errors);
141#endif
142
146 void readyRead();
147 void finished();
153#ifndef QT_NO_NETWORKPROXY
155#endif
157 void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemaining);
158private:
159 Q_DECLARE_PRIVATE(QHttpNetworkReply)
160 friend class QHttpSocketEngine;
166 friend class QSpdyProtocolHandler;
167};
168
169
171{
172public:
173 QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl());
175 qint64 readStatus(QIODevice *socket);
176 bool parseStatus(QByteArrayView status);
177 qint64 readHeader(QIODevice *socket);
178 void parseHeader(QByteArrayView header);
179 void appendHeaderField(const QByteArray &name, const QByteArray &data);
181 qint64 readBodyVeryFast(QIODevice *socket, char *b);
182 qint64 readBodyFast(QIODevice *socket, QByteDataBuffer *rb);
183 void clear();
184 void clearHttpLayerInformation();
185
186 qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size);
187 qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out);
188 qint64 getChunkSize(QIODevice *in, qint64 *chunkSize);
189
190 bool isRedirecting() const;
191 bool shouldEmitSignals();
192 bool expectContent();
193 void eraseData();
194
195 qint64 bytesAvailable() const;
196 bool isChunked();
197 bool isConnectionCloseEnabled();
198
199 bool isCompressed() const;
200 void removeAutoDecompressHeader();
201
214
216 bool ssl;
221 QByteArray fragment; // used for header, status, chunk header etc, not for reply data
231 QPointer<QHttpNetworkConnection> connection;
232 QPointer<QHttpNetworkConnectionChannel> connectionChannel;
234
236
237 QByteDataBuffer responseData; // uncompressed body
239
241 bool h2Used;
243
246};
247
248
249
250
252
253#endif // QHTTPNETWORKREPLY_H
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
QPointer< QHttpNetworkConnection > connection
QPointer< QHttpNetworkConnectionChannel > connectionChannel
void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemaining)
void authenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *authenticator)
void socketStartedConnecting()
void dataSendProgress(qint64 done, qint64 total)
void sslErrors(const QList< QSslError > &errors)
void dataReadProgress(qint64 done, qint64 total)
\inmodule QtCore \reentrant
Definition qiodevice.h:34
The QNetworkProxy class provides a network layer proxy.
NetworkError
Indicates all possible error conditions found during the processing of the request.
\inmodule QtCore
Definition qobject.h:103
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
b clear()
else opt state
[0]
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
DBusConnection * connection
static QString header(const QString &name)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLConfig config
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint name
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint in
request setUrl(QUrl("http://qt-project.org"))
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define Q_MOC_INCLUDE(...)
#define Q_SIGNALS
long long qint64
Definition qtypes.h:60
ReturnedValue read(const char *data)
QTextStream out(stdout)
[7]
QUrl url("example.com")
[constructor-url-reference]
QTcpSocket * socket
[1]
QNetworkRequest request(url)
reply ignoreSslErrors(expectedSslErrors)
QNetworkProxy proxy
[0]
sslSocket setSslConfiguration(config)