Qt 6.x
The Qt SDK
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
46
48
55{
57public:
58
59 explicit QHttpNetworkReply(const QUrl &url = QUrl(), QObject *parent = nullptr);
60 virtual ~QHttpNetworkReply();
61
62 QUrl url() const override;
63 void setUrl(const QUrl &url) override;
64
65 int majorVersion() const override;
66 int minorVersion() const override;
67 void setMajorVersion(int version);
68 void setMinorVersion(int version);
69
70 qint64 contentLength() const override;
71 void setContentLength(qint64 length) override;
72
74 QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue = QByteArray()) const override;
75 void setHeaderField(const QByteArray &name, const QByteArray &data) override;
76 void appendHeaderField(const QByteArray &name, const QByteArray &data);
77 void parseHeader(const QByteArray &header); // used for testing
78
80 void setRequest(const QHttpNetworkRequest &request);
81
82 int statusCode() const;
83 void setStatusCode(int code);
84
85 QString errorString() const;
86 void setErrorString(const QString &error);
87
88 QNetworkReply::NetworkError errorCode() const;
89
90 QString reasonPhrase() const;
91 void setReasonPhrase(const QString &reason);
92
93 qint64 bytesAvailable() const;
94 qint64 bytesAvailableNextBlock() const;
95 bool readAnyAvailable() const;
96 QByteArray readAny();
97 QByteArray readAll();
98 QByteArray read(qint64 amount);
99 qint64 sizeNextBlock();
100 void setDownstreamLimited(bool t);
101 void setReadBufferSize(qint64 size);
102
103 bool supportsUserProvidedDownloadBuffer();
104 void setUserProvidedDownloadBuffer(char*);
105 char* userProvidedDownloadBuffer();
106
107 void abort();
108
109 bool isAborted() const;
110 bool isFinished() const;
111
112 bool isPipeliningUsed() const;
113 bool isHttp2Used() const;
114 void setHttp2WasUsed(bool h2Used);
115 qint64 removedContentLength() const;
116
117 bool isRedirecting() const;
118
120
121 QUrl redirectUrl() const;
122 void setRedirectUrl(const QUrl &url);
123
124 static bool isHttpRedirect(int statusCode);
125
126 bool isCompressed() const;
127
128#ifndef QT_NO_SSL
129 QSslConfiguration sslConfiguration() const;
131 void ignoreSslErrors();
132 void ignoreSslErrors(const QList<QSslError> &errors);
133
135 void encrypted();
136 void sslErrors(const QList<QSslError> &errors);
138#endif
139
143 void readyRead();
144 void finished();
150#ifndef QT_NO_NETWORKPROXY
152#endif
154 void redirected(const QUrl &url, int httpStatus, int maxRedirectsRemaining);
155private:
156 Q_DECLARE_PRIVATE(QHttpNetworkReply)
157 friend class QHttpSocketEngine;
163 friend class QSpdyProtocolHandler;
164};
165
166
168{
169public:
170 QHttpNetworkReplyPrivate(const QUrl &newUrl = QUrl());
172 qint64 readStatus(QAbstractSocket *socket);
173 bool parseStatus(const QByteArray &status);
174 qint64 readHeader(QAbstractSocket *socket);
175 void parseHeader(const QByteArray &header);
176 void appendHeaderField(const QByteArray &name, const QByteArray &data);
178 qint64 readBodyVeryFast(QAbstractSocket *socket, char *b);
179 qint64 readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb);
180 bool findChallenge(bool forProxy, QByteArray &challenge) const;
181 void clear();
182 void clearHttpLayerInformation();
183
184 qint64 readReplyBodyRaw(QAbstractSocket *in, QByteDataBuffer *out, qint64 size);
185 qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out);
186 qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize);
187
188 bool isRedirecting() const;
189 bool shouldEmitSignals();
190 bool expectContent();
191 void eraseData();
192
193 qint64 bytesAvailable() const;
194 bool isChunked();
195 bool isConnectionCloseEnabled();
196
197 bool isCompressed() const;
198 void removeAutoDecompressHeader();
199
210 Aborted
212
214 bool ssl;
219 QByteArray fragment; // used for header, status, chunk header etc, not for reply data
232
234
235 QByteDataBuffer responseData; // uncompressed body
237
239 bool h2Used;
241
244};
245
246
247
248
250
251#endif // QHTTPNETWORKREPLY_H
The QAbstractSocket class provides the base functionality common to all socket types.
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
virtual qint64 contentLength() const =0
virtual QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const =0
virtual void setHeaderField(const QByteArray &name, const QByteArray &data)=0
virtual void setContentLength(qint64 length)=0
virtual int minorVersion() const =0
virtual int majorVersion() const =0
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)
Definition qlist.h:74
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:90
\inmodule QtCore
Definition qpointer.h:18
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:127
\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)
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:55
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)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent