Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qnetworkaccessmanager.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 QNETWORKACCESSMANAGER_H
5#define QNETWORKACCESSMANAGER_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtNetwork/qnetworkrequest.h>
9#include <QtCore/QString>
10#include <QtCore/QList>
11#include <QtCore/QObject>
12#ifndef QT_NO_SSL
13#include <QtNetwork/QSslConfiguration>
14#include <QtNetwork/QSslPreSharedKeyAuthenticator>
15#endif
16Q_MOC_INCLUDE(<QtNetwork/QSslError>)
17
19
20class QIODevice;
22class QAuthenticator;
23class QByteArray;
24class QNetworkCookie;
26class QNetworkReply;
27class QNetworkProxy;
29class QSslError;
30class QHstsPolicy;
31class QHttpMultiPart;
32
35class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
36{
38
39
40public:
41 enum Operation {
42 HeadOperation = 1,
48
49 UnknownOperation = 0
50 };
51
52 explicit QNetworkAccessManager(QObject *parent = nullptr);
54
55 virtual QStringList supportedSchemes() const;
56
57 void clearAccessCache();
58
59 void clearConnectionCache();
60
61#ifndef QT_NO_NETWORKPROXY
62 QNetworkProxy proxy() const;
63 void setProxy(const QNetworkProxy &proxy);
64 QNetworkProxyFactory *proxyFactory() const;
65 void setProxyFactory(QNetworkProxyFactory *factory);
66#endif
67
70
71 QNetworkCookieJar *cookieJar() const;
72 void setCookieJar(QNetworkCookieJar *cookieJar);
73
74 void setStrictTransportSecurityEnabled(bool enabled);
75 bool isStrictTransportSecurityEnabled() const;
76 void enableStrictTransportSecurityStore(bool enabled, const QString &storeDir = QString());
77 bool isStrictTransportSecurityStoreEnabled() const;
78 void addStrictTransportSecurityHosts(const QList<QHstsPolicy> &knownHosts);
79 QList<QHstsPolicy> strictTransportSecurityHosts() const;
80
87 QNetworkReply *deleteResource(const QNetworkRequest &request);
88 QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = nullptr);
89 QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data);
90
91#if QT_CONFIG(http) || defined(Q_OS_WASM)
94 QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart);
95#endif
96
97#ifndef QT_NO_SSL
98 void connectToHostEncrypted(const QString &hostName, quint16 port = 443,
100 void connectToHostEncrypted(const QString &hostName, quint16 port,
101 const QSslConfiguration &sslConfiguration,
102 const QString &peerName);
103#endif
104 void connectToHost(const QString &hostName, quint16 port = 80);
105
106 void setRedirectPolicy(QNetworkRequest::RedirectPolicy policy);
107 QNetworkRequest::RedirectPolicy redirectPolicy() const;
108
109 bool autoDeleteReplies() const;
110 void setAutoDeleteReplies(bool autoDelete);
111
112 int transferTimeout() const;
113 void setTransferTimeout(int timeout = QNetworkRequest::DefaultTransferTimeoutConstant);
114
116#ifndef QT_NO_NETWORKPROXY
118#endif
121#ifndef QT_NO_SSL
125#endif
126
127protected:
128 virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
129 QIODevice *outgoingData = nullptr);
130
131protected Q_SLOTS:
132 QStringList supportedSchemesImplementation() const;
133
134private:
139
140#ifdef Q_OS_WASM
141 friend class QNetworkReplyWasmImpl;
142#endif
143 Q_DECLARE_PRIVATE(QNetworkAccessManager)
144 Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
145#ifndef QT_NO_SSL
146 Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))
147#endif
148};
149
151
152#endif
The QAbstractNetworkCache class provides the interface for cache implementations.
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
The QHstsPolicy class specifies that a host supports HTTP Strict Transport Security policy (HSTS).
Definition qhstspolicy.h:19
The QHttpMultiPart class resembles a MIME multipart message to be sent over HTTP.
\inmodule QtCore \reentrant
Definition qiodevice.h:34
Definition qlist.h:74
The QNetworkAccessManager class allows the application to send network requests and receive replies.
void finished(QNetworkReply *reply)
This signal is emitted whenever a pending network reply is finished.
void preSharedKeyAuthenticationRequired(QNetworkReply *reply, QSslPreSharedKeyAuthenticator *authenticator)
void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
This signal is emitted whenever a final server requests authentication before it delivers the request...
void encrypted(QNetworkReply *reply)
void sslErrors(QNetworkReply *reply, const QList< QSslError > &errors)
This signal is emitted if the SSL/TLS session encountered errors during the set up,...
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
This signal is emitted whenever a proxy requests authentication and QNetworkAccessManager cannot find...
The QNetworkCookieJar class implements a simple jar of QNetworkCookie objects.
The QNetworkCookie class holds one network cookie.
The QNetworkProxyFactory class provides fine-grained proxy selection.
The QNetworkProxy class provides a network layer proxy.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
\inmodule QtCore
Definition qobject.h:90
The QSslConfiguration class holds the configuration and state of an SSL connection.
static QSslConfiguration defaultConfiguration()
Returns the default SSL configuration to be used in new SSL connections.
The QSslError class provides an SSL error.
Definition qsslerror.h:21
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
static QDBusError::ErrorType get(const char *name)
EGLOutputPortEXT port
GLbitfield GLuint64 timeout
[4]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_OBJECT
#define Q_SLOTS
#define Q_MOC_INCLUDE(...)
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
unsigned short quint16
Definition qtypes.h:43
sock connectToHost(url.host(), url.port(80))
QItemEditorFactory * factory
QSizePolicy policy
QHttpMultiPart * multiPart
[0]
QNetworkRequest request(url)
QNetworkReply * reply
manager setCache(diskCache)
QNetworkProxy proxy
[0]
serverSocket setProxy(QNetworkProxy::NoProxy)
[0]
socket connectToHostEncrypted("imap.example.com", 993)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent