Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qt6-changes.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page network-changes-qt6.html
6
\title Changes to Qt Network
7
\ingroup changes-qt-5-to-6
8
\brief Migrate Qt Network to Qt 6.
9
10
Qt 6 is a result of the conscious effort to make the framework more
11
efficient and easy to use.
12
13
We try to maintain binary and source compatibility for all the public
14
APIs in each release. But some changes were inevitable in an effort to
15
make Qt a better framework.
16
17
In this topic we summarize those changes in Qt Network, and provide
18
guidance to handle them.
19
20
\section1 API changes
21
22
\section2 Ambiguous name overloads
23
24
Several ambiguous overloaded functions are removed. The error() signal
25
is replaced by errorOccurred() in QAbstractSocket and its heirs
26
(QTcpSocket, QUdpSocket, QLocalSocket, and QSslSocket), and in QNetworkReply.
27
Code such as:
28
29
\code
30
connect(socket, qOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error),
31
this, &SomeClass::errorSlot);
32
\endcode
33
34
must therefore be changed to:
35
36
\code
37
connect(socket, &QAbstractSocket::errorOccurred, this, &SomeClass::errorSlot);
38
\endcode
39
40
In QSslSocket, the function that returns a list of errors encountered
41
during the TLS handshake:
42
43
\code
44
QList<QSslError> sslErrors() const;
45
\endcode
46
47
is renamed to sslHandshakeErrors():
48
49
\code
50
const auto tlsErrors = socket.sslHandshakeErrors();
51
\endcode
52
53
\section2 Bearer management is removed
54
55
The classes QNetworkConfiguration and QNetworkConfigurationManager are removed in Qt 6.
56
Consequently, the following member functions of QNetworkAccessManager are also removed:
57
58
\code
59
void setConfiguration(const QNetworkConfiguration &config);
60
QNetworkConfiguration configuration() const;
61
QNetworkConfiguration activeConfiguration() const;
62
void setNetworkAccessible(NetworkAccessibility accessible);
63
NetworkAccessibility networkAccessible() const;
64
void networkSessionConnected();
65
\endcode
66
67
QNetworkInformation, initially introduced in Qt 6.1, aims to replace some
68
aspects of the bearer management API. It works by providing a unified API
69
which subscribes to changes to the network as notified by the operating
70
system.
71
72
QNetworkInformation::reachability(), introduced in Qt 6.1, replaces the
73
QNetworkAccessManager::networkAccessible() function, while adding more
74
detailed information about the reachability of the network. See its
75
documentation for more details.
76
77
In Qt 6.2 QNetworkInformation gained the ability to detect captive portals.
78
79
In Qt 6.3 QNetworkInformation gained QNetworkInformation::transportMedium()
80
and QNetworkInformation::isMetered().
81
82
\section2 Deleted enumerators
83
84
Several enumerators are removed in QtNetwork. This includes constants
85
for no longer supported protocols and functionality:
86
87
\list
88
\li QSsl::SslV2;
89
\li QSsl::SslV3;
90
\li QSsl::TlsV1SslV3;
91
\li QNetworkRequest::SpdyAllowedAttribute;
92
\li QNetworkRequest::SpdyWasUsedAttribute;
93
\li QNetworkAccessManager::UnknownAccessibility;
94
\li QNetworkAccessManager::NotAccessible;
95
\li QNetworkAccessManager::Accessible
96
\endlist
97
98
and enumerators whose names did not follow proper naming conventions:
99
100
\list
101
\li QSsl::TlsV1 (QSsl::TlsV1_0 is the proper name);
102
\li QNetworkRequest::HTTP2AllowedAttribute (use QNetworkRequest::Http2AllowedAttribute);
103
\li QNetworkRequest::HTTP2WasUsedAttribute (use QNetworkRequest::Http2WasUsedAttribute).
104
\endlist
105
106
QNetworkRequest::FollowRedirectsAttribute is removed in Qt 6, see
107
\l {Redirect policies}{the section about redirects handling} below.
108
109
\section2 Configuring QSslSocket
110
111
The following deprecated functions are removed in Qt 6:
112
113
\code
114
QList<QSslCipher> ciphers() const;
115
void setCiphers(const QList<QSslCipher> &ciphers);
116
void setCiphers(const QString &ciphers);
117
static void setDefaultCiphers(const QList<QSslCipher> &ciphers);
118
static QList<QSslCipher> defaultCiphers();
119
static QList<QSslCipher> supportedCiphers();
120
QList<QSslCipher> ciphers() const;
121
void setCiphers(const QList<QSslCipher> &ciphers);
122
void setCiphers(const QString &ciphers);
123
static void setDefaultCiphers(const QList<QSslCipher> &ciphers);
124
static QList<QSslCipher> defaultCiphers();
125
static QList<QSslCipher> supportedCiphers();
126
bool addCaCertificates(const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
127
QRegExp::PatternSyntax syntax = QRegExp::FixedString);
128
void addCaCertificate(const QSslCertificate &certificate);
129
void addCaCertificates(const QList<QSslCertificate> &certificates);
130
void setCaCertificates(const QList<QSslCertificate> &certificates);
131
QList<QSslCertificate> caCertificates() const;
132
static bool addDefaultCaCertificates(const QString &path, QSsl::EncodingFormat format = QSsl::Pem,
133
QRegExp::PatternSyntax syntax = QRegExp::FixedString);
134
static void addDefaultCaCertificate(const QSslCertificate &certificate);
135
static void addDefaultCaCertificates(const QList<QSslCertificate> &certificates);
136
static void setDefaultCaCertificates(const QList<QSslCertificate> &certificates);
137
static QList<QSslCertificate> defaultCaCertificates();
138
static QList<QSslCertificate> systemCaCertificates();
139
\endcode
140
141
Use QSslConfiguration and its member functions to set these parameters, e.g.:
142
143
\code
144
auto sslConfiguration = QSslConfiguration::defaultConfiguration();
145
sslConfiguration.setCiphers("ECDHE-ECDSA-AES256-SHA384");
146
// Set other parameters here ...
147
socket.setSslConfiguration(sslConfiguration);
148
\endcode
149
150
\section1 Changes in QNetworkAccessManager's default behavior
151
152
\section2 Redirect policies
153
154
In Qt 6, the default redirect policy has changed from manual to
155
QNetworkRequest::NoLessSafeRedirectPolicy. If your application relies
156
on manual redirect handling (it connects its slot to the QNetworkReply::redirected
157
signal), you have to explicitly set this policy when creating a request:
158
159
\code
160
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy);
161
\endcode
162
163
\section2 HTTP/2 is enabled by default
164
165
In Qt 6 QNetworkAccessManager enables HTTP/2 protocol by default. Depending on the
166
scheme ("https" or "http"), QNetworkAccessManager will use the Application Layer
167
Protocol Negotiation TLS extension or "protocol upgrade" HTTP header to negotiate HTTP/2.
168
If HTTP/2 cannot be negotiated, the access manager will fall back to using HTTP/1.1.
169
If your application can only use HTTP/1.1, you have to disable HTTP/2 manually
170
on a new request:
171
172
\code
173
request.setAttribute(QNetworkRequest::Http2AllowedAttribute, false);
174
\endcode
175
176
\section2 QNetworkAccessManager now guards against archive bombs
177
178
Starting with Qt 6.2 QNetworkAccessManager will guard against compressed
179
files that decompress to files which are much larger than their compressed
180
form by erroring out the reply if the decompression ratio exceeds a certain
181
threshold.
182
This check is only applied to files larger than a certain size, which can be
183
customized (or disabled by passing -1) by calling
184
\l{QNetworkRequest::setDecompressedSafetyCheckThreshold()}.
185
*/
qtbase
src
network
doc
src
qt6-changes.qdoc
Generated on
for Qt by
1.14.0