Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qnetworkreply.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 QNETWORKREPLY_H
5#define QNETWORKREPLY_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/QIODevice>
9#include <QtCore/QString>
10#include <QtCore/QVariant>
11
12#include <QtNetwork/QNetworkRequest>
13#include <QtNetwork/QNetworkAccessManager>
14
16
17
18class QUrl;
19class QVariant;
20class QAuthenticator;
22class QSslError;
24
26class Q_NETWORK_EXPORT QNetworkReply: public QIODevice
27{
29public:
32
33 // network layer errors [relating to the destination server] (1-99):
34 ConnectionRefusedError = 1,
45 UnknownNetworkError = 99,
46
47 // proxy errors (101-199):
48 ProxyConnectionRefusedError = 101,
53 UnknownProxyError = 199,
54
55 // content errors (201-299):
56 ContentAccessDenied = 201,
63 UnknownContentError = 299,
64
65 // protocol errors
66 ProtocolUnknownError = 301,
68 ProtocolFailure = 399,
69
70 // Server side errors (401-499)
71 InternalServerError = 401,
74 UnknownServerError = 499
75 };
76 Q_ENUM(NetworkError)
77
79
80 // reimplemented from QIODevice
81 virtual void close() override;
82 virtual bool isSequential() const override;
83
84 // like QAbstractSocket:
85 qint64 readBufferSize() const;
86 virtual void setReadBufferSize(qint64 size);
87
89 QNetworkAccessManager::Operation operation() const;
91 NetworkError error() const;
92 bool isFinished() const;
93 bool isRunning() const;
94 QUrl url() const;
95
96 // "cooked" headers
98
99 // raw headers:
100 bool hasRawHeader(const QByteArray &headerName) const;
101 QList<QByteArray> rawHeaderList() const;
102 QByteArray rawHeader(const QByteArray &headerName) const;
103
105 const QList<RawHeaderPair>& rawHeaderPairs() const;
106
107 // attributes
109
110#if QT_CONFIG(ssl)
111 QSslConfiguration sslConfiguration() const;
112 void setSslConfiguration(const QSslConfiguration &configuration);
113 void ignoreSslErrors(const QList<QSslError> &errors);
114#endif
115
116public Q_SLOTS:
117 virtual void abort() = 0;
118 virtual void ignoreSslErrors();
119
124 void finished();
126#if QT_CONFIG(ssl)
127 void encrypted();
128 void sslErrors(const QList<QSslError> &errors);
129 void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
130#endif
131 void redirected(const QUrl &url);
133
134 void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
135 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
136
137protected:
138 explicit QNetworkReply(QObject *parent = nullptr);
140 virtual qint64 writeData(const char *data, qint64 len) override;
141
142 void setOperation(QNetworkAccessManager::Operation operation);
143 void setRequest(const QNetworkRequest &request);
144 void setError(NetworkError errorCode, const QString &errorString);
145 void setFinished(bool);
146 void setUrl(const QUrl &url);
150
151#if QT_CONFIG(ssl)
152 virtual void sslConfigurationImplementation(QSslConfiguration &) const;
153 virtual void setSslConfigurationImplementation(const QSslConfiguration &);
154 virtual void ignoreSslErrorsImplementation(const QList<QSslError> &);
155#endif
156
157private:
158 Q_DECLARE_PRIVATE(QNetworkReply)
159};
160
162
164 QNetworkReply__NetworkError, Q_NETWORK_EXPORT)
165
166#endif
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
Definition qlist.h:74
The QNetworkAccessManager class allows the application to send network requests and receive replies.
Operation
Indicates the operation this reply is processing.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
void socketStartedConnecting()
void redirectAllowed()
void errorOccurred(QNetworkReply::NetworkError)
void requestSent()
void metaDataChanged()
\omit FIXME: Update name? \endomit
void uploadProgress(qint64 bytesSent, qint64 bytesTotal)
This signal is emitted to indicate the progress of the upload part of this network request,...
void redirected(const QUrl &url)
QPair< QByteArray, QByteArray > RawHeaderPair
RawHeaderPair is a QPair<QByteArray, QByteArray> where the first QByteArray is the header name and th...
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
This signal is emitted to indicate the progress of the download part of this network request,...
virtual void abort()=0
Aborts the operation immediately and close down any network connections still open.
NetworkError
Indicates all possible error conditions found during the processing of the request.
@ ContentOperationNotPermittedError
@ OperationNotImplementedError
@ TemporaryNetworkFailureError
@ BackgroundRequestNotAllowedError
@ ProtocolInvalidOperationError
@ ProxyAuthenticationRequiredError
@ AuthenticationRequiredError
void finished()
This signal is emitted when the reply has finished processing.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
KnownHeaders
List of known header types that QNetworkRequest parses.
\inmodule QtCore
Definition qobject.h:90
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslError class provides an SSL error.
Definition qsslerror.h:21
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
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
DBusConnection const char DBusError * error
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
EGLOutputLayerEXT EGLint attribute
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1355
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
static void setError(QJsonObject *response, const QString &msg)
request setUrl(QUrl("http://qt-project.org"))
static bool isRunning()
Definition main.cpp:358
@ NoError
Definition main.cpp:34
#define Q_ENUM(x)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
long long qint64
Definition qtypes.h:55
QUrl url("example.com")
[constructor-url-reference]
app setAttribute(Qt::AA_DontShowIconsInMenus)
QNetworkAccessManager manager
QNetworkRequest request(url)
textPart setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""))
imagePart setRawHeader("Content-ID", "my@content.id")
reply ignoreSslErrors(expectedSslErrors)
sslSocket setSslConfiguration(config)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent