qnetworkaccessmanager.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessmanager.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qnetworkaccessmanager.h"-
35#include "qnetworkaccessmanager_p.h"-
36#include "qnetworkrequest.h"-
37#include "qnetworkreply.h"-
38#include "qnetworkreply_p.h"-
39#include "qnetworkcookie.h"-
40#include "qnetworkcookiejar.h"-
41#include "qabstractnetworkcache.h"-
42-
43#include "QtNetwork/qnetworksession.h"-
44#include "QtNetwork/private/qsharednetworksession_p.h"-
45-
46#include "qnetworkaccessftpbackend_p.h"-
47#include "qnetworkaccessfilebackend_p.h"-
48#include "qnetworkaccessdebugpipebackend_p.h"-
49#include "qnetworkaccesscachebackend_p.h"-
50#include "qnetworkreplydataimpl_p.h"-
51#include "qnetworkreplyfileimpl_p.h"-
52-
53#include "QtCore/qbuffer.h"-
54#include "QtCore/qurl.h"-
55#include "QtCore/qvector.h"-
56#include "QtNetwork/private/qauthenticator_p.h"-
57#include "QtNetwork/qsslconfiguration.h"-
58#include "QtNetwork/qnetworkconfigmanager.h"-
59#include "QtNetwork/qhttpmultipart.h"-
60#include "qhttpmultipart_p.h"-
61-
62#include "qnetworkreplyhttpimpl_p.h"-
63-
64#include "qthread.h"-
65-
66QT_BEGIN_NAMESPACE-
67-
68Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend)
executed 10 times by 10 tests: end of block
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 10 times by 10 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 91 times by 10 tests: return &holder.value;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
guard.load() =...c::InitializedDescription
TRUEevaluated 10 times by 10 tests
Evaluated by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-91
69#ifndef QT_NO_FTP-
70Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend)
executed 10 times by 10 tests: end of block
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 10 times by 10 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 91 times by 10 tests: return &holder.value;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
guard.load() =...c::InitializedDescription
TRUEevaluated 10 times by 10 tests
Evaluated by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-91
71#endif // QT_NO_FTP-
72-
73#ifdef QT_BUILD_INTERNAL-
74Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend)
executed 10 times by 10 tests: end of block
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 10 times by 10 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
executed 91 times by 10 tests: return &holder.value;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
guard.load() =...c::InitializedDescription
TRUEevaluated 10 times by 10 tests
Evaluated by:
  • tst_qabstractnetworkcache - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qnetworkaccessmanager - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkconfigurationmanagerqappless - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qxmlinputsource - unknown status
  • tst_qxmlstream - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-91
75#endif-
76-
77#if defined(Q_OS_MACX)-
78-
79#include <CoreServices/CoreServices.h>-
80#include <SystemConfiguration/SystemConfiguration.h>-
81#include <Security/SecKeychain.h>-
82-
83bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password)-
84{-
85 OSStatus err;-
86 SecKeychainItemRef itemRef;-
87 bool retValue = false;-
88 SecProtocolType protocolType = kSecProtocolTypeAny;-
89 if (scheme.compare(QLatin1String("ftp"),Qt::CaseInsensitive)==0) {-
90 protocolType = kSecProtocolTypeFTPProxy;-
91 } else if (scheme.compare(QLatin1String("http"),Qt::CaseInsensitive)==0-
92 || scheme.compare(QLatin1String("preconnect-http"),Qt::CaseInsensitive)==0) {-
93 protocolType = kSecProtocolTypeHTTPProxy;-
94 } else if (scheme.compare(QLatin1String("https"),Qt::CaseInsensitive)==0-
95 || scheme.compare(QLatin1String("preconnect-https"),Qt::CaseInsensitive)==0) {-
96 protocolType = kSecProtocolTypeHTTPSProxy;-
97 }-
98 QByteArray proxyHostnameUtf8(proxyHostname.toUtf8());-
99 err = SecKeychainFindInternetPassword(NULL,-
100 proxyHostnameUtf8.length(), proxyHostnameUtf8.constData(),-
101 0,NULL,-
102 0, NULL,-
103 0, NULL,-
104 0,-
105 protocolType,-
106 kSecAuthenticationTypeAny,-
107 0, NULL,-
108 &itemRef);-
109 if (err == noErr) {-
110-
111 SecKeychainAttribute attr;-
112 SecKeychainAttributeList attrList;-
113 UInt32 length;-
114 void *outData;-
115-
116 attr.tag = kSecAccountItemAttr;-
117 attr.length = 0;-
118 attr.data = NULL;-
119-
120 attrList.count = 1;-
121 attrList.attr = &attr;-
122-
123 if (SecKeychainItemCopyContent(itemRef, NULL, &attrList, &length, &outData) == noErr) {-
124 username = QString::fromUtf8((const char*)attr.data, attr.length);-
125 password = QString::fromUtf8((const char*)outData, length);-
126 SecKeychainItemFreeContent(&attrList,outData);-
127 retValue = true;-
128 }-
129 CFRelease(itemRef);-
130 }-
131 return retValue;-
132}-
133#endif-
134-
135-
136-
137static void ensureInitialized()-
138{-
139#ifndef QT_NO_FTP-
140 (void) ftpBackend();-
141#endif-
142-
143#ifdef QT_BUILD_INTERNAL-
144 (void) debugpipeBackend();-
145#endif-
146-
147 // leave this one last since it will query the special QAbstractFileEngines-
148 (void) fileBackend();-
149}
executed 91 times by 10 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
91
150-
151/*!-
152 \class QNetworkAccessManager-
153 \brief The QNetworkAccessManager class allows the application to-
154 send network requests and receive replies-
155 \since 4.4-
156-
157 \ingroup network-
158 \inmodule QtNetwork-
159 \reentrant-
160-
161 The Network Access API is constructed around one QNetworkAccessManager-
162 object, which holds the common configuration and settings for the requests-
163 it sends. It contains the proxy and cache configuration, as well as the-
164 signals related to such issues, and reply signals that can be used to-
165 monitor the progress of a network operation. One QNetworkAccessManager-
166 should be enough for the whole Qt application.-
167-
168 Once a QNetworkAccessManager object has been created, the application can-
169 use it to send requests over the network. A group of standard functions-
170 are supplied that take a request and optional data, and each return a-
171 QNetworkReply object. The returned object is used to obtain any data-
172 returned in response to the corresponding request.-
173-
174 A simple download off the network could be accomplished with:-
175 \snippet code/src_network_access_qnetworkaccessmanager.cpp 0-
176-
177 QNetworkAccessManager has an asynchronous API.-
178 When the \tt replyFinished slot above is called, the parameter it-
179 takes is the QNetworkReply object containing the downloaded data-
180 as well as meta-data (headers, etc.).-
181-
182 \note After the request has finished, it is the responsibility of the user-
183 to delete the QNetworkReply object at an appropriate time. Do not directly-
184 delete it inside the slot connected to finished(). You can use the-
185 deleteLater() function.-
186-
187 \note QNetworkAccessManager queues the requests it receives. The number-
188 of requests executed in parallel is dependent on the protocol.-
189 Currently, for the HTTP protocol on desktop platforms, 6 requests are-
190 executed in parallel for one host/port combination.-
191-
192 A more involved example, assuming the manager is already existent,-
193 can be:-
194 \snippet code/src_network_access_qnetworkaccessmanager.cpp 1-
195-
196 \section1 Network and Roaming Support-
197-
198 With the addition of the \l {Bearer Management} API to Qt 4.7-
199 QNetworkAccessManager gained the ability to manage network connections.-
200 QNetworkAccessManager can start the network interface if the device is-
201 offline and terminates the interface if the current process is the last-
202 one to use the uplink. Note that some platforms utilize grace periods from-
203 when the last application stops using a uplink until the system actually-
204 terminates the connectivity link. Roaming is equally transparent. Any-
205 queued/pending network requests are automatically transferred to the new-
206 access point.-
207-
208 Clients wanting to utilize this feature should not require any changes. In fact-
209 it is likely that existing platform specific connection code can simply be-
210 removed from the application.-
211-
212 \note The network and roaming support in QNetworkAccessManager is conditional-
213 upon the platform supporting connection management. The-
214 \l QNetworkConfigurationManager::NetworkSessionRequired can be used to-
215 detect whether QNetworkAccessManager utilizes this feature.-
216-
217 \sa QNetworkRequest, QNetworkReply, QNetworkProxy-
218*/-
219-
220/*!-
221 \enum QNetworkAccessManager::Operation-
222-
223 Indicates the operation this reply is processing.-
224-
225 \value HeadOperation retrieve headers operation (created-
226 with head())-
227-
228 \value GetOperation retrieve headers and download contents-
229 (created with get())-
230-
231 \value PutOperation upload contents operation (created-
232 with put())-
233-
234 \value PostOperation send the contents of an HTML form for-
235 processing via HTTP POST (created with post())-
236-
237 \value DeleteOperation delete contents operation (created with-
238 deleteResource())-
239-
240 \value CustomOperation custom operation (created with-
241 sendCustomRequest()) \since 4.7-
242-
243 \omitvalue UnknownOperation-
244-
245 \sa QNetworkReply::operation()-
246*/-
247-
248/*!-
249 \enum QNetworkAccessManager::NetworkAccessibility-
250-
251 Indicates whether the network is accessible via this network access manager.-
252-
253 \value UnknownAccessibility The network accessibility cannot be determined.-
254 \value NotAccessible The network is not currently accessible, either because there-
255 is currently no network coverage or network access has been-
256 explicitly disabled by a call to setNetworkAccessible().-
257 \value Accessible The network is accessible.-
258-
259 \sa networkAccessible-
260*/-
261-
262/*!-
263 \property QNetworkAccessManager::networkAccessible-
264 \brief whether the network is currently accessible via this network access manager.-
265-
266 \since 4.7-
267-
268 If the network is \l {NotAccessible}{not accessible} the network access manager will not-
269 process any new network requests, all such requests will fail with an error. Requests with-
270 URLs with the file:// scheme will still be processed.-
271-
272 By default the value of this property reflects the physical state of the device. Applications-
273 may override it to disable all network requests via this network access manager by calling-
274-
275 \snippet code/src_network_access_qnetworkaccessmanager.cpp 4-
276-
277 Network requests can be re-enabled again, and this property will resume to-
278 reflect the actual device state by calling-
279-
280 \snippet code/src_network_access_qnetworkaccessmanager.cpp 5-
281-
282 \note Calling setNetworkAccessible() does not change the network state.-
283*/-
284-
285/*!-
286 \fn void QNetworkAccessManager::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible)-
287-
288 This signal is emitted when the value of the \l networkAccessible property changes.-
289 \a accessible is the new network accessibility.-
290*/-
291-
292/*!-
293 \fn void QNetworkAccessManager::networkSessionConnected()-
294-
295 \since 4.7-
296-
297 \internal-
298-
299 This signal is emitted when the status of the network session changes into a usable (Connected)-
300 state. It is used to signal to QNetworkReplys to start or migrate their network operation once-
301 the network session has been opened or finished roaming.-
302*/-
303-
304/*!-
305 \fn void QNetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)-
306-
307 This signal is emitted whenever a proxy requests authentication-
308 and QNetworkAccessManager cannot find a valid, cached-
309 credential. The slot connected to this signal should fill in the-
310 credentials for the proxy \a proxy in the \a authenticator object.-
311-
312 QNetworkAccessManager will cache the credentials internally. The-
313 next time the proxy requests authentication, QNetworkAccessManager-
314 will automatically send the same credential without emitting the-
315 proxyAuthenticationRequired signal again.-
316-
317 If the proxy rejects the credentials, QNetworkAccessManager will-
318 emit the signal again.-
319-
320 \sa proxy(), setProxy(), authenticationRequired()-
321*/-
322-
323/*!-
324 \fn void QNetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)-
325-
326 This signal is emitted whenever a final server requests-
327 authentication before it delivers the requested contents. The slot-
328 connected to this signal should fill the credentials for the-
329 contents (which can be determined by inspecting the \a reply-
330 object) in the \a authenticator object.-
331-
332 QNetworkAccessManager will cache the credentials internally and-
333 will send the same values if the server requires authentication-
334 again, without emitting the authenticationRequired() signal. If it-
335 rejects the credentials, this signal will be emitted again.-
336-
337 \note To have the request not send credentials you must not call-
338 setUser() or setPassword() on the \a authenticator object. This-
339 will result in the \l finished() signal being emitted with a-
340 \l QNetworkReply with error \l {QNetworkReply::} {AuthenticationRequiredError}.-
341-
342 \note It is not possible to use a QueuedConnection to connect to-
343 this signal, as the connection will fail if the authenticator has-
344 not been filled in with new information when the signal returns.-
345-
346 \sa proxyAuthenticationRequired(), QAuthenticator::setUser(), QAuthenticator::setPassword()-
347*/-
348-
349/*!-
350 \fn void QNetworkAccessManager::finished(QNetworkReply *reply)-
351-
352 This signal is emitted whenever a pending network reply is-
353 finished. The \a reply parameter will contain a pointer to the-
354 reply that has just finished. This signal is emitted in tandem-
355 with the QNetworkReply::finished() signal.-
356-
357 See QNetworkReply::finished() for information on the status that-
358 the object will be in.-
359-
360 \note Do not delete the \a reply object in the slot connected to this-
361 signal. Use deleteLater().-
362-
363 \sa QNetworkReply::finished(), QNetworkReply::error()-
364*/-
365-
366/*!-
367 \fn void QNetworkAccessManager::encrypted(QNetworkReply *reply)-
368 \since 5.1-
369-
370 This signal is emitted when an SSL/TLS session has successfully-
371 completed the initial handshake. At this point, no user data-
372 has been transmitted. The signal can be used to perform-
373 additional checks on the certificate chain, for example to-
374 notify users when the certificate for a website has changed. The-
375 \a reply parameter specifies which network reply is responsible.-
376 If the reply does not match the expected criteria then it should-
377 be aborted by calling QNetworkReply::abort() by a slot connected-
378 to this signal. The SSL configuration in use can be inspected-
379 using the QNetworkReply::sslConfiguration() method.-
380-
381 Internally, QNetworkAccessManager may open multiple connections-
382 to a server, in order to allow it process requests in parallel.-
383 These connections may be reused, which means that the encrypted()-
384 signal would not be emitted. This means that you are only-
385 guaranteed to receive this signal for the first connection to a-
386 site in the lifespan of the QNetworkAccessManager.-
387-
388 \sa QSslSocket::encrypted()-
389 \sa QNetworkReply::encrypted()-
390*/-
391-
392/*!-
393 \fn void QNetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors)-
394-
395 This signal is emitted if the SSL/TLS session encountered errors-
396 during the set up, including certificate verification errors. The-
397 \a errors parameter contains the list of errors and \a reply is-
398 the QNetworkReply that is encountering these errors.-
399-
400 To indicate that the errors are not fatal and that the connection-
401 should proceed, the QNetworkReply::ignoreSslErrors() function should be called-
402 from the slot connected to this signal. If it is not called, the-
403 SSL session will be torn down before any data is exchanged-
404 (including the URL).-
405-
406 This signal can be used to display an error message to the user-
407 indicating that security may be compromised and display the-
408 SSL settings (see sslConfiguration() to obtain it). If the user-
409 decides to proceed after analyzing the remote certificate, the-
410 slot should call ignoreSslErrors().-
411-
412 \sa QSslSocket::sslErrors(), QNetworkReply::sslErrors(),-
413 QNetworkReply::sslConfiguration(), QNetworkReply::ignoreSslErrors()-
414*/-
415-
416/*!-
417 \fn void QNetworkAccessManager::preSharedKeyAuthenticationRequired(QNetworkReply *reply, QSslPreSharedKeyAuthenticator *authenticator)-
418 \since 5.5-
419-
420 This signal is emitted if the SSL/TLS handshake negotiates a PSK-
421 ciphersuite, and therefore a PSK authentication is then required.-
422 The \a reply object is the QNetworkReply that is negotiating-
423 such ciphersuites.-
424-
425 When using PSK, the client must send to the server a valid identity and a-
426 valid pre shared key, in order for the SSL handshake to continue.-
427 Applications can provide this information in a slot connected to this-
428 signal, by filling in the passed \a authenticator object according to their-
429 needs.-
430-
431 \note Ignoring this signal, or failing to provide the required credentials,-
432 will cause the handshake to fail, and therefore the connection to be aborted.-
433-
434 \note The \a authenticator object is owned by the reply and must not be-
435 deleted by the application.-
436-
437 \sa QSslPreSharedKeyAuthenticator-
438*/-
439-
440/*!-
441 Constructs a QNetworkAccessManager object that is the center of-
442 the Network Access API and sets \a parent as the parent object.-
443*/-
444QNetworkAccessManager::QNetworkAccessManager(QObject *parent)-
445 : QObject(*new QNetworkAccessManagerPrivate, parent)-
446{-
447 ensureInitialized();-
448-
449 qRegisterMetaType<QNetworkReply::NetworkError>();-
450#ifndef QT_NO_NETWORKPROXY-
451 qRegisterMetaType<QNetworkProxy>();-
452#endif-
453#ifndef QT_NO_SSL-
454 qRegisterMetaType<QList<QSslError> >();-
455 qRegisterMetaType<QSslConfiguration>();-
456 qRegisterMetaType<QSslPreSharedKeyAuthenticator *>();-
457#endif-
458 qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >();-
459#ifndef QT_NO_HTTP-
460 qRegisterMetaType<QHttpNetworkRequest>();-
461#endif-
462 qRegisterMetaType<QNetworkReply::NetworkError>();-
463 qRegisterMetaType<QSharedPointer<char> >();-
464-
465#ifndef QT_NO_BEARERMANAGEMENT-
466 Q_D(QNetworkAccessManager);-
467 // if a session is required, we track online state through-
468 // the QNetworkSession's signals if a request is already made.-
469 // we need to track current accessibility state by default-
470 //-
471 connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)),-
472 SLOT(_q_onlineStateChanged(bool)));-
473 connect(&d->networkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration &)),-
474 SLOT(_q_configurationChanged(const QNetworkConfiguration &)));-
475-
476#endif-
477}
executed 91 times by 10 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
91
478-
479/*!-
480 Destroys the QNetworkAccessManager object and frees up any-
481 resources. Note that QNetworkReply objects that are returned from-
482 this class have this object set as their parents, which means that-
483 they will be deleted along with it if you don't call-
484 QObject::setParent() on them.-
485*/-
486QNetworkAccessManager::~QNetworkAccessManager()-
487{-
488#ifndef QT_NO_NETWORKPROXY-
489 delete d_func()->proxyFactory;-
490#endif-
491-
492 // Delete the QNetworkReply children first.-
493 // Else a QAbstractNetworkCache might get deleted in ~QObject-
494 // before a QNetworkReply that accesses the QAbstractNetworkCache-
495 // object in its destructor.-
496 qDeleteAll(findChildren<QNetworkReply *>());-
497 // The other children will be deleted in this ~QObject-
498 // FIXME instead of this "hack" make the QNetworkReplyImpl-
499 // properly watch the cache deletion, e.g. via a QWeakPointer.-
500}
executed 92 times by 11 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_spdy - unknown status
92
501-
502#ifndef QT_NO_NETWORKPROXY-
503/*!-
504 Returns the QNetworkProxy that the requests sent using this-
505 QNetworkAccessManager object will use. The default value for the-
506 proxy is QNetworkProxy::DefaultProxy.-
507-
508 \sa setProxy(), setProxyFactory(), proxyAuthenticationRequired()-
509*/-
510QNetworkProxy QNetworkAccessManager::proxy() const-
511{-
512 return d_func()->proxy;
never executed: return d_func()->proxy;
0
513}-
514-
515/*!-
516 Sets the proxy to be used in future requests to be \a proxy. This-
517 does not affect requests that have already been sent. The-
518 proxyAuthenticationRequired() signal will be emitted if the proxy-
519 requests authentication.-
520-
521 A proxy set with this function will be used for all requests-
522 issued by QNetworkAccessManager. In some cases, it might be-
523 necessary to select different proxies depending on the type of-
524 request being sent or the destination host. If that's the case,-
525 you should consider using setProxyFactory().-
526-
527 \sa proxy(), proxyAuthenticationRequired()-
528*/-
529void QNetworkAccessManager::setProxy(const QNetworkProxy &proxy)-
530{-
531 Q_D(QNetworkAccessManager);-
532 delete d->proxyFactory;-
533 d->proxy = proxy;-
534 d->proxyFactory = 0;-
535}
executed 788 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
788
536-
537/*!-
538 \fn QNetworkProxyFactory *QNetworkAccessManager::proxyFactory() const-
539 \since 4.5-
540-
541 Returns the proxy factory that this QNetworkAccessManager object-
542 is using to determine the proxies to be used for requests.-
543-
544 Note that the pointer returned by this function is managed by-
545 QNetworkAccessManager and could be deleted at any time.-
546-
547 \sa setProxyFactory(), proxy()-
548*/-
549QNetworkProxyFactory *QNetworkAccessManager::proxyFactory() const-
550{-
551 return d_func()->proxyFactory;
never executed: return d_func()->proxyFactory;
0
552}-
553-
554/*!-
555 \since 4.5-
556-
557 Sets the proxy factory for this class to be \a factory. A proxy-
558 factory is used to determine a more specific list of proxies to be-
559 used for a given request, instead of trying to use the same proxy-
560 value for all requests.-
561-
562 All queries sent by QNetworkAccessManager will have type-
563 QNetworkProxyQuery::UrlRequest.-
564-
565 For example, a proxy factory could apply the following rules:-
566 \list-
567 \li if the target address is in the local network (for example,-
568 if the hostname contains no dots or if it's an IP address in-
569 the organization's range), return QNetworkProxy::NoProxy-
570 \li if the request is FTP, return an FTP proxy-
571 \li if the request is HTTP or HTTPS, then return an HTTP proxy-
572 \li otherwise, return a SOCKSv5 proxy server-
573 \endlist-
574-
575 The lifetime of the object \a factory will be managed by-
576 QNetworkAccessManager. It will delete the object when necessary.-
577-
578 \note If a specific proxy is set with setProxy(), the factory will not-
579 be used.-
580-
581 \sa proxyFactory(), setProxy(), QNetworkProxyQuery-
582*/-
583void QNetworkAccessManager::setProxyFactory(QNetworkProxyFactory *factory)-
584{-
585 Q_D(QNetworkAccessManager);-
586 delete d->proxyFactory;-
587 d->proxyFactory = factory;-
588 d->proxy = QNetworkProxy();-
589}
executed 20 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
20
590#endif-
591-
592/*!-
593 \since 4.5-
594-
595 Returns the cache that is used to store data obtained from the network.-
596-
597 \sa setCache()-
598*/-
599QAbstractNetworkCache *QNetworkAccessManager::cache() const-
600{-
601 Q_D(const QNetworkAccessManager);-
602 return d->networkCache;
never executed: return d->networkCache;
0
603}-
604-
605/*!-
606 \since 4.5-
607-
608 Sets the manager's network cache to be the \a cache specified. The cache-
609 is used for all requests dispatched by the manager.-
610-
611 Use this function to set the network cache object to a class that implements-
612 additional features, like saving the cookies to permanent storage.-
613-
614 \note QNetworkAccessManager takes ownership of the \a cache object.-
615-
616 QNetworkAccessManager by default does not have a set cache.-
617 Qt provides a simple disk cache, QNetworkDiskCache, which can be used.-
618-
619 \sa cache(), QNetworkRequest::CacheLoadControl-
620*/-
621void QNetworkAccessManager::setCache(QAbstractNetworkCache *cache)-
622{-
623 Q_D(QNetworkAccessManager);-
624 if (d->networkCache != cache) {
d->networkCache != cacheDescription
TRUEevaluated 94 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 614 times by 1 test
Evaluated by:
  • tst_QNetworkReply
94-614
625 delete d->networkCache;-
626 d->networkCache = cache;-
627 if (d->networkCache)
d->networkCacheDescription
TRUEevaluated 69 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 25 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
25-69
628 d->networkCache->setParent(this);
executed 69 times by 3 tests: d->networkCache->setParent(this);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
69
629 }
executed 94 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
94
630}
executed 708 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
708
631-
632/*!-
633 Returns the QNetworkCookieJar that is used to store cookies-
634 obtained from the network as well as cookies that are about to be-
635 sent.-
636-
637 \sa setCookieJar()-
638*/-
639QNetworkCookieJar *QNetworkAccessManager::cookieJar() const-
640{-
641 Q_D(const QNetworkAccessManager);-
642 if (!d->cookieJar)
!d->cookieJarDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-13
643 d->createCookieJar();
never executed: d->createCookieJar();
0
644 return d->cookieJar;
executed 13 times by 1 test: return d->cookieJar;
Executed by:
  • tst_QNetworkReply
13
645}-
646-
647/*!-
648 Sets the manager's cookie jar to be the \a cookieJar specified.-
649 The cookie jar is used by all requests dispatched by the manager.-
650-
651 Use this function to set the cookie jar object to a class that-
652 implements additional features, like saving the cookies to permanent-
653 storage.-
654-
655 \note QNetworkAccessManager takes ownership of the \a cookieJar object.-
656-
657 If \a cookieJar is in the same thread as this QNetworkAccessManager,-
658 it will set the parent of the \a cookieJar-
659 so that the cookie jar is deleted when this-
660 object is deleted as well. If you want to share cookie jars-
661 between different QNetworkAccessManager objects, you may want to-
662 set the cookie jar's parent to 0 after calling this function.-
663-
664 QNetworkAccessManager by default does not implement any cookie-
665 policy of its own: it accepts all cookies sent by the server, as-
666 long as they are well formed and meet the minimum security-
667 requirements (cookie domain matches the request's and cookie path-
668 matches the request's). In order to implement your own security-
669 policy, override the QNetworkCookieJar::cookiesForUrl() and-
670 QNetworkCookieJar::setCookiesFromUrl() virtual functions. Those-
671 functions are called by QNetworkAccessManager when it detects a-
672 new cookie.-
673-
674 \sa cookieJar(), QNetworkCookieJar::cookiesForUrl(), QNetworkCookieJar::setCookiesFromUrl()-
675*/-
676void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar)-
677{-
678 Q_D(QNetworkAccessManager);-
679 d->cookieJarCreated = true;-
680 if (d->cookieJar != cookieJar) {
d->cookieJar != cookieJarDescription
TRUEnever evaluated
FALSEnever evaluated
0
681 if (d->cookieJar && d->cookieJar->parent() == this)
d->cookieJarDescription
TRUEnever evaluated
FALSEnever evaluated
d->cookieJar->parent() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
682 delete d->cookieJar;
never executed: delete d->cookieJar;
0
683 d->cookieJar = cookieJar;-
684 if (thread() == cookieJar->thread())
thread() == co...eJar->thread()Description
TRUEnever evaluated
FALSEnever evaluated
0
685 d->cookieJar->setParent(this);
never executed: d->cookieJar->setParent(this);
0
686 }
never executed: end of block
0
687}
never executed: end of block
0
688-
689/*!-
690 Posts a request to obtain the network headers for \a request-
691 and returns a new QNetworkReply object which will contain such headers.-
692-
693 The function is named after the HTTP request associated (HEAD).-
694*/-
695QNetworkReply *QNetworkAccessManager::head(const QNetworkRequest &request)-
696{-
697 return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request));
executed 27 times by 1 test: return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request));
Executed by:
  • tst_QNetworkReply
27
698}-
699-
700/*!-
701 Posts a request to obtain the contents of the target \a request-
702 and returns a new QNetworkReply object opened for reading which emits the-
703 \l{QIODevice::readyRead()}{readyRead()} signal whenever new data-
704 arrives.-
705-
706 The contents as well as associated headers will be downloaded.-
707-
708 \sa post(), put(), deleteResource(), sendCustomRequest()-
709*/-
710QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request)-
711{-
712 return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request));
executed 776 times by 9 tests: return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
776
713}-
714-
715/*!-
716 Sends an HTTP POST request to the destination specified by \a request-
717 and returns a new QNetworkReply object opened for reading that will-
718 contain the reply sent by the server. The contents of the \a data-
719 device will be uploaded to the server.-
720-
721 \a data must be open for reading and must remain valid until the-
722 finished() signal is emitted for this reply.-
723-
724 \note Sending a POST request on protocols other than HTTP and-
725 HTTPS is undefined and will probably fail.-
726-
727 \sa get(), put(), deleteResource(), sendCustomRequest()-
728*/-
729QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QIODevice *data)-
730{-
731 return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data));
executed 157 times by 3 tests: return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data));
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
157
732}-
733-
734/*!-
735 \overload-
736-
737 Sends the contents of the \a data byte array to the destination-
738 specified by \a request.-
739*/-
740QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, const QByteArray &data)-
741{-
742 QBuffer *buffer = new QBuffer;-
743 buffer->setData(data);-
744 buffer->open(QIODevice::ReadOnly);-
745-
746 QNetworkReply *reply = post(request, buffer);-
747 buffer->setParent(reply);-
748 return reply;
executed 54 times by 3 tests: return reply;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
54
749}-
750-
751/*!-
752 \since 4.8-
753-
754 \overload-
755-
756 Sends the contents of the \a multiPart message to the destination-
757 specified by \a request.-
758-
759 This can be used for sending MIME multipart messages over HTTP.-
760-
761 \sa QHttpMultiPart, QHttpPart, put()-
762*/-
763QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QHttpMultiPart *multiPart)-
764{-
765 QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart);-
766 QIODevice *device = multiPart->d_func()->device;-
767 QNetworkReply *reply = post(newRequest, device);-
768 return reply;
executed 24 times by 2 tests: return reply;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
24
769}-
770-
771/*!-
772 \since 4.8-
773-
774 \overload-
775-
776 Sends the contents of the \a multiPart message to the destination-
777 specified by \a request.-
778-
779 This can be used for sending MIME multipart messages over HTTP.-
780-
781 \sa QHttpMultiPart, QHttpPart, post()-
782*/-
783QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QHttpMultiPart *multiPart)-
784{-
785 QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart);-
786 QIODevice *device = multiPart->d_func()->device;-
787 QNetworkReply *reply = put(newRequest, device);-
788 return reply;
never executed: return reply;
0
789}-
790-
791/*!-
792 Uploads the contents of \a data to the destination \a request and-
793 returnes a new QNetworkReply object that will be open for reply.-
794-
795 \a data must be opened for reading when this function is called-
796 and must remain valid until the finished() signal is emitted for-
797 this reply.-
798-
799 Whether anything will be available for reading from the returned-
800 object is protocol dependent. For HTTP, the server may send a-
801 small HTML page indicating the upload was successful (or not).-
802 Other protocols will probably have content in their replies.-
803-
804 \note For HTTP, this request will send a PUT request, which most servers-
805 do not allow. Form upload mechanisms, including that of uploading-
806 files through HTML forms, use the POST mechanism.-
807-
808 \sa get(), post(), deleteResource(), sendCustomRequest()-
809*/-
810QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QIODevice *data)-
811{-
812 return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data));
executed 95 times by 2 tests: return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data));
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
95
813}-
814-
815/*!-
816 \overload-
817-
818 Sends the contents of the \a data byte array to the destination-
819 specified by \a request.-
820*/-
821QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, const QByteArray &data)-
822{-
823 QBuffer *buffer = new QBuffer;-
824 buffer->setData(data);-
825 buffer->open(QIODevice::ReadOnly);-
826-
827 QNetworkReply *reply = put(request, buffer);-
828 buffer->setParent(reply);-
829 return reply;
executed 55 times by 2 tests: return reply;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
55
830}-
831-
832/*!-
833 \since 4.6-
834-
835 Sends a request to delete the resource identified by the URL of \a request.-
836-
837 \note This feature is currently available for HTTP only, performing an-
838 HTTP DELETE request.-
839-
840 \sa get(), post(), put(), sendCustomRequest()-
841*/-
842QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &request)-
843{-
844 return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request));
executed 7 times by 1 test: return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request));
Executed by:
  • tst_QNetworkReply
7
845}-
846-
847#ifndef QT_NO_BEARERMANAGEMENT-
848-
849/*!-
850 \since 4.7-
851-
852 Sets the network configuration that will be used when creating the-
853 \l {QNetworkSession}{network session} to \a config.-
854-
855 The network configuration is used to create and open a network session before any request that-
856 requires network access is process. If no network configuration is explicitly set via this-
857 function the network configuration returned by-
858 QNetworkConfigurationManager::defaultConfiguration() will be used.-
859-
860 To restore the default network configuration set the network configuration to the value-
861 returned from QNetworkConfigurationManager::defaultConfiguration().-
862-
863 Setting a network configuration means that the QNetworkAccessManager instance will only-
864 be using the specified one. In particular, if the default network configuration changes-
865 (upon e.g. Wifi being available), this new configuration needs to be enabled-
866 manually if desired.-
867-
868 \snippet code/src_network_access_qnetworkaccessmanager.cpp 2-
869-
870 If an invalid network configuration is set, a network session will not be created. In this-
871 case network requests will be processed regardless, but may fail. For example:-
872-
873 \snippet code/src_network_access_qnetworkaccessmanager.cpp 3-
874-
875 \sa configuration(), QNetworkSession-
876*/-
877void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config)-
878{-
879 Q_D(QNetworkAccessManager);-
880 d->networkConfiguration = config;-
881 d->customNetworkConfiguration = true;-
882 d->createSession(config);-
883}
executed 26 times by 3 tests: end of block
Executed by:
  • tst_QNetworkAccessManager
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
26
884-
885/*!-
886 \since 4.7-
887-
888 Returns the network configuration that will be used to create the-
889 \l {QNetworkSession}{network session} which will be used when processing network requests.-
890-
891 \sa setConfiguration(), activeConfiguration()-
892*/-
893QNetworkConfiguration QNetworkAccessManager::configuration() const-
894{-
895 Q_D(const QNetworkAccessManager);-
896-
897 QSharedPointer<QNetworkSession> session(d->getNetworkSession());-
898 if (session) {
sessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
899 return session->configuration();
never executed: return session->configuration();
0
900 } else {-
901 QNetworkConfigurationManager manager;-
902 return manager.defaultConfiguration();
never executed: return manager.defaultConfiguration();
0
903 }-
904}-
905-
906/*!-
907 \since 4.7-
908-
909 Returns the current active network configuration.-
910-
911 If the network configuration returned by configuration() is of type-
912 QNetworkConfiguration::ServiceNetwork this function will return the current active child-
913 network configuration of that configuration. Otherwise returns the same network configuration-
914 as configuration().-
915-
916 Use this function to return the actual network configuration currently in use by the network-
917 session.-
918-
919 \sa configuration()-
920*/-
921QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const-
922{-
923 Q_D(const QNetworkAccessManager);-
924-
925 QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());-
926 QNetworkConfigurationManager manager;-
927 if (networkSession) {
networkSessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
928 return manager.configurationFromIdentifier(
never executed: return manager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
0
929 networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
never executed: return manager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
0
930 } else {-
931 return manager.defaultConfiguration();
never executed: return manager.defaultConfiguration();
0
932 }-
933}-
934-
935/*!-
936 \since 4.7-
937-
938 Overrides the reported network accessibility. If \a accessible is NotAccessible the reported-
939 network accessiblity will always be NotAccessible. Otherwise the reported network-
940 accessibility will reflect the actual device state.-
941*/-
942void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkAccessibility accessible)-
943{-
944 Q_D(QNetworkAccessManager);-
945-
946 d->defaultAccessControl = accessible == NotAccessible ? false : true;
accessible == NotAccessibleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
1-2
947-
948 if (d->networkAccessible != accessible) {
d->networkAcce... != accessibleDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
FALSEnever evaluated
0-3
949 NetworkAccessibility previous = networkAccessible();-
950 d->networkAccessible = accessible;-
951 NetworkAccessibility current = networkAccessible();-
952 if (previous != current)
previous != currentDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
FALSEnever evaluated
0-3
953 emit networkAccessibleChanged(current);
executed 3 times by 1 test: networkAccessibleChanged(current);
Executed by:
  • tst_QNetworkAccessManager
3
954 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkAccessManager
3
955}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkAccessManager
3
956-
957/*!-
958 \since 4.7-
959-
960 Returns the current network accessibility.-
961*/-
962QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccessible() const-
963{-
964 Q_D(const QNetworkAccessManager);-
965-
966 if (d->networkConfiguration.state().testFlag(QNetworkConfiguration::Undefined))
d->networkConf...on::Undefined)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
0-12
967 return UnknownAccessibility;
never executed: return UnknownAccessibility;
0
968-
969 if (d->networkSessionRequired) {
d->networkSessionRequiredDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
0-12
970 QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());-
971 if (networkSession) {
networkSessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
972 // d->online holds online/offline state of this network session.-
973 if (d->online)
d->onlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
974 return d->networkAccessible;
never executed: return d->networkAccessible;
0
975 else-
976 return NotAccessible;
never executed: return NotAccessible;
0
977 } else {-
978 if (d->defaultAccessControl) {
d->defaultAccessControlDescription
TRUEnever evaluated
FALSEnever evaluated
0
979 if (d->online)
d->onlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
980 return d->networkAccessible;
never executed: return d->networkAccessible;
0
981 else-
982 return NotAccessible;
never executed: return NotAccessible;
0
983 }-
984 return (d->networkAccessible);
never executed: return (d->networkAccessible);
0
985 }-
986 } else {-
987 if (d->online)
d->onlineDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
FALSEnever evaluated
0-12
988 return d->networkAccessible;
executed 12 times by 1 test: return d->networkAccessible;
Executed by:
  • tst_QNetworkAccessManager
12
989 else-
990 return NotAccessible;
never executed: return NotAccessible;
0
991 }-
992}-
993-
994/*!-
995 \internal-
996-
997 Returns the network session currently in use.-
998 This can be changed at any time, ownership remains with the QNetworkAccessManager-
999*/-
1000const QWeakPointer<const QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession(const QNetworkAccessManager *q)-
1001{-
1002 return q->d_func()->networkSessionWeakRef;
executed 30 times by 1 test: return q->d_func()->networkSessionWeakRef;
Executed by:
  • tst_QNetworkReply
30
1003}-
1004-
1005QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const-
1006{-
1007 if (networkSessionStrongRef)
networkSessionStrongRefDescription
TRUEevaluated 4125 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
28-4125
1008 return networkSessionStrongRef;
executed 4125 times by 8 tests: return networkSessionStrongRef;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
4125
1009 return networkSessionWeakRef.toStrongRef();
executed 28 times by 2 tests: return networkSessionWeakRef.toStrongRef();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
28
1010}-
1011-
1012#endif // QT_NO_BEARERMANAGEMENT-
1013-
1014-
1015#ifndef QT_NO_SSL-
1016/*!-
1017 \since 5.2-
1018-
1019 Initiates a connection to the host given by \a hostName at port \a port, using-
1020 \a sslConfiguration. This function is useful to complete the TCP and SSL handshake-
1021 to a host before the HTTPS request is made, resulting in a lower network latency.-
1022-
1023 \note Preconnecting a SPDY connection can be done by calling setAllowedNextProtocols()-
1024 on \a sslConfiguration with QSslConfiguration::NextProtocolSpdy3_0 contained in-
1025 the list of allowed protocols. When using SPDY, one single connection per host is-
1026 enough, i.e. calling this method multiple times per host will not result in faster-
1027 network transactions.-
1028-
1029 \note This function has no possibility to report errors.-
1030-
1031 \sa connectToHost(), get(), post(), put(), deleteResource()-
1032*/-
1033void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quint16 port,-
1034 const QSslConfiguration &sslConfiguration)-
1035{-
1036 QUrl url;-
1037 url.setHost(hostName);-
1038 url.setPort(port);-
1039 url.setScheme(QLatin1String("preconnect-https"));-
1040 QNetworkRequest request(url);-
1041 if (sslConfiguration != QSslConfiguration::defaultConfiguration())
sslConfigurati...onfiguration()Description
TRUEnever evaluated
FALSEnever evaluated
0
1042 request.setSslConfiguration(sslConfiguration);
never executed: request.setSslConfiguration(sslConfiguration);
0
1043-
1044 // There is no way to enable SPDY via a request, so we need to check-
1045 // the ssl configuration whether SPDY is allowed here.-
1046 if (sslConfiguration.allowedNextProtocols().contains(
sslConfigurati...otocolSpdy3_0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1047 QSslConfiguration::NextProtocolSpdy3_0))
sslConfigurati...otocolSpdy3_0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1048 request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
never executed: request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);
0
1049-
1050 get(request);-
1051}
never executed: end of block
0
1052#endif-
1053-
1054/*!-
1055 \since 5.2-
1056-
1057 Initiates a connection to the host given by \a hostName at port \a port.-
1058 This function is useful to complete the TCP handshake-
1059 to a host before the HTTP request is made, resulting in a lower network latency.-
1060-
1061 \note This function has no possibility to report errors.-
1062-
1063 \sa connectToHostEncrypted(), get(), post(), put(), deleteResource()-
1064*/-
1065void QNetworkAccessManager::connectToHost(const QString &hostName, quint16 port)-
1066{-
1067 QUrl url;-
1068 url.setHost(hostName);-
1069 url.setPort(port);-
1070 url.setScheme(QLatin1String("preconnect-http"));-
1071 QNetworkRequest request(url);-
1072 get(request);-
1073}
never executed: end of block
0
1074-
1075/*!-
1076 \since 4.7-
1077-
1078 Sends a custom request to the server identified by the URL of \a request.-
1079-
1080 It is the user's responsibility to send a \a verb to the server that is valid-
1081 according to the HTTP specification.-
1082-
1083 This method provides means to send verbs other than the common ones provided-
1084 via get() or post() etc., for instance sending an HTTP OPTIONS command.-
1085-
1086 If \a data is not empty, the contents of the \a data-
1087 device will be uploaded to the server; in that case, data must be open for-
1088 reading and must remain valid until the finished() signal is emitted for this reply.-
1089-
1090 \note This feature is currently available for HTTP(S) only.-
1091-
1092 \sa get(), post(), put(), deleteResource()-
1093*/-
1094QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data)-
1095{-
1096 QNetworkRequest newRequest(request);-
1097 newRequest.setAttribute(QNetworkRequest::CustomVerbAttribute, verb);-
1098 return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data));
executed 7 times by 1 test: return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data));
Executed by:
  • tst_QNetworkReply
7
1099}-
1100-
1101/*!-
1102 Returns a new QNetworkReply object to handle the operation \a op-
1103 and request \a req. The device \a outgoingData is always 0 for Get and-
1104 Head requests, but is the value passed to post() and put() in-
1105 those operations (the QByteArray variants will pass a QBuffer-
1106 object).-
1107-
1108 The default implementation calls QNetworkCookieJar::cookiesForUrl()-
1109 on the cookie jar set with setCookieJar() to obtain the cookies to-
1110 be sent to the remote server.-
1111-
1112 The returned object must be in an open state.-
1113*/-
1114QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op,-
1115 const QNetworkRequest &req,-
1116 QIODevice *outgoingData)-
1117{-
1118 Q_D(QNetworkAccessManager);-
1119-
1120 bool isLocalFile = req.url().isLocalFile();-
1121 QString scheme = req.url().scheme();-
1122-
1123 // fast path for GET on file:// URLs-
1124 // The QNetworkAccessFileBackend will right now only be used for PUT-
1125 if (op == QNetworkAccessManager::GetOperation
op == QNetwork...::GetOperationDescription
TRUEevaluated 776 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
FALSEevaluated 293 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
293-776
1126 || op == QNetworkAccessManager::HeadOperation) {
op == QNetwork...:HeadOperationDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 266 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
27-266
1127 if (isLocalFile
isLocalFileDescription
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlStream
FALSEevaluated 775 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
28-775
1128#ifdef Q_OS_ANDROID-
1129 || scheme == QLatin1String("assets")-
1130#endif-
1131 || scheme == QLatin1String("qrc")) {
scheme == QLatin1String("qrc")Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 773 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
2-773
1132 return new QNetworkReplyFileImpl(this, req, op);
executed 30 times by 2 tests: return new QNetworkReplyFileImpl(this, req, op);
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
30
1133 }-
1134-
1135 if (scheme == QLatin1String("data"))
scheme == QLat...String("data")Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 743 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
30-743
1136 return new QNetworkReplyDataImpl(this, req, op);
executed 30 times by 1 test: return new QNetworkReplyDataImpl(this, req, op);
Executed by:
  • tst_QNetworkReply
30
1137-
1138 // A request with QNetworkRequest::AlwaysCache does not need any bearer management-
1139 QNetworkRequest::CacheLoadControl mode =-
1140 static_cast<QNetworkRequest::CacheLoadControl>(-
1141 req.attribute(QNetworkRequest::CacheLoadControlAttribute,-
1142 QNetworkRequest::PreferNetwork).toInt());-
1143 if (mode == QNetworkRequest::AlwaysCache) {
mode == QNetwo...t::AlwaysCacheDescription
TRUEevaluated 14 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 729 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
14-729
1144 // FIXME Implement a QNetworkReplyCacheImpl instead, see QTBUG-15106-
1145 QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);-
1146 QNetworkReplyImplPrivate *priv = reply->d_func();-
1147 priv->manager = this;-
1148 priv->backend = new QNetworkAccessCacheBackend();-
1149 priv->backend->manager = this->d_func();-
1150 priv->backend->setParent(reply);-
1151 priv->backend->reply = priv;-
1152 priv->setup(op, req, outgoingData);-
1153 return reply;
executed 14 times by 3 tests: return reply;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
14
1154 }-
1155 }
executed 729 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
729
1156-
1157#ifndef QT_NO_BEARERMANAGEMENT-
1158 // Return a disabled network reply if network access is disabled.-
1159 // Except if the scheme is empty or file://.-
1160 if (d->networkAccessible == NotAccessible && !isLocalFile) {
d->networkAcce... NotAccessibleDescription
TRUEnever evaluated
FALSEevaluated 995 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
!isLocalFileDescription
TRUEnever evaluated
FALSEnever evaluated
0-995
1161 return new QDisabledNetworkReply(this, req, op);
never executed: return new QDisabledNetworkReply(this, req, op);
0
1162 }-
1163-
1164 if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) {
!d->networkSessionStrongRefDescription
TRUEevaluated 196 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 799 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
d->initializeSessionDescription
TRUEevaluated 85 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 111 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
!d->networkCon...er().isEmpty()Description
TRUEevaluated 111 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-799
1165 QNetworkConfigurationManager manager;-
1166 if (!d->networkConfiguration.identifier().isEmpty()) {
!d->networkCon...er().isEmpty()Description
TRUEevaluated 196 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-196
1167 if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined)-
1168 && d->networkConfiguration != manager.defaultConfiguration())
d->networkConf...onfiguration()Description
TRUEnever evaluated
FALSEevaluated 196 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-196
1169 d->createSession(manager.defaultConfiguration());
never executed: d->createSession(manager.defaultConfiguration());
0
1170 else-
1171 d->createSession(d->networkConfiguration);
executed 196 times by 7 tests: d->createSession(d->networkConfiguration);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
196
1172-
1173 } else {-
1174 if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
manager.capabi...essionRequiredDescription
TRUEnever evaluated
FALSEnever evaluated
0
1175 d->createSession(manager.defaultConfiguration());
never executed: d->createSession(manager.defaultConfiguration());
0
1176 else-
1177 d->initializeSession = false;
never executed: d->initializeSession = false;
0
1178 }-
1179 }-
1180#endif-
1181-
1182 QNetworkRequest request = req;-
1183 if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
!request.heade...der).isValid()Description
TRUEevaluated 992 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
3-992
1184 outgoingData && !outgoingData->isSequential()) {
outgoingDataDescription
TRUEevaluated 252 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 740 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
!outgoingData->isSequential()Description
TRUEevaluated 159 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 93 times by 1 test
Evaluated by:
  • tst_QNetworkReply
93-740
1185 // request has no Content-Length-
1186 // but the data that is outgoing is random-access-
1187 request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size());-
1188 }
executed 159 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
159
1189-
1190 if (static_cast<QNetworkRequest::LoadControl>
static_cast<QN...est::AutomaticDescription
TRUEevaluated 995 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-995
1191 (request.attribute(QNetworkRequest::CookieLoadControlAttribute,
static_cast<QN...est::AutomaticDescription
TRUEevaluated 995 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-995
1192 QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) {
static_cast<QN...est::AutomaticDescription
TRUEevaluated 995 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-995
1193 if (d->cookieJar) {
d->cookieJarDescription
TRUEevaluated 650 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 345 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
345-650
1194 QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url());-
1195 if (!cookies.isEmpty())
!cookies.isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 642 times by 1 test
Evaluated by:
  • tst_QNetworkReply
8-642
1196 request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
executed 8 times by 1 test: request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
Executed by:
  • tst_QNetworkReply
8
1197 }
executed 650 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
650
1198 }
executed 995 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
995
1199-
1200#ifndef QT_NO_HTTP-
1201 // Since Qt 5 we use the new QNetworkReplyHttpImpl-
1202 if (scheme == QLatin1String("http") || scheme == QLatin1String("preconnect-http")
scheme == QLat...String("http")Description
TRUEevaluated 655 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 340 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
scheme == QLat...connect-http")Description
TRUEnever evaluated
FALSEevaluated 340 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
0-655
1203#ifndef QT_NO_SSL-
1204 || scheme == QLatin1String("https") || scheme == QLatin1String("preconnect-https")
scheme == QLat...tring("https")Description
TRUEevaluated 232 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QNetworkReply
scheme == QLat...onnect-https")Description
TRUEnever evaluated
FALSEevaluated 108 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-232
1205#endif-
1206 ) {-
1207 QNetworkReplyHttpImpl *reply = new QNetworkReplyHttpImpl(this, request, op, outgoingData);-
1208#ifndef QT_NO_BEARERMANAGEMENT-
1209 connect(this, SIGNAL(networkSessionConnected()),-
1210 reply, SLOT(_q_networkSessionConnected()));-
1211#endif-
1212 return reply;
executed 887 times by 8 tests: return reply;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
887
1213 }-
1214#endif // QT_NO_HTTP-
1215-
1216 // first step: create the reply-
1217 QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);-
1218#ifndef QT_NO_BEARERMANAGEMENT-
1219 if (!isLocalFile) {
!isLocalFileDescription
TRUEevaluated 69 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_QNetworkReply
39-69
1220 connect(this, SIGNAL(networkSessionConnected()),-
1221 reply, SLOT(_q_networkSessionConnected()));-
1222 }
executed 69 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
69
1223#endif-
1224 QNetworkReplyImplPrivate *priv = reply->d_func();-
1225 priv->manager = this;-
1226-
1227 // second step: fetch cached credentials-
1228 // This is not done for the time being, we should use signal emissions to request-
1229 // the credentials from cache.-
1230-
1231 // third step: find a backend-
1232 priv->backend = d->findBackend(op, request);-
1233-
1234 if (priv->backend) {
priv->backendDescription
TRUEevaluated 104 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
4-104
1235 priv->backend->setParent(reply);-
1236 priv->backend->reply = priv;-
1237 }
executed 104 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
104
1238-
1239#ifndef QT_NO_SSL-
1240 reply->setSslConfiguration(request.sslConfiguration());-
1241#endif-
1242-
1243 // fourth step: setup the reply-
1244 priv->setup(op, request, outgoingData);-
1245-
1246 return reply;
executed 108 times by 1 test: return reply;
Executed by:
  • tst_QNetworkReply
108
1247}-
1248-
1249/*!-
1250 \since 5.2-
1251-
1252 Lists all the URL schemes supported by the access manager.-
1253-
1254 \sa supportedSchemesImplementation()-
1255*/-
1256QStringList QNetworkAccessManager::supportedSchemes() const-
1257{-
1258 QStringList schemes;-
1259 QNetworkAccessManager *self = const_cast<QNetworkAccessManager *>(this); // We know we call a const slot-
1260 QMetaObject::invokeMethod(self, "supportedSchemesImplementation", Qt::DirectConnection,-
1261 Q_RETURN_ARG(QStringList, schemes));-
1262 schemes.removeDuplicates();-
1263 return schemes;
never executed: return schemes;
0
1264}-
1265-
1266/*!-
1267 \since 5.2-
1268-
1269 Lists all the URL schemes supported by the access manager.-
1270-
1271 You should not call this function directly; use-
1272 QNetworkAccessManager::supportedSchemes() instead.-
1273-
1274 Reimplement this slot to provide your own supported schemes-
1275 in a QNetworkAccessManager subclass. It is for instance necessary-
1276 when your subclass provides support for new protocols.-
1277-
1278 Because of binary compatibility constraints, the supportedSchemes()-
1279 method (introduced in Qt 5.2) is not virtual. Instead, supportedSchemes()-
1280 will dynamically detect and call this slot.-
1281-
1282 \sa supportedSchemes()-
1283*/-
1284QStringList QNetworkAccessManager::supportedSchemesImplementation() const-
1285{-
1286 Q_D(const QNetworkAccessManager);-
1287-
1288 QStringList schemes = d->backendSupportedSchemes();-
1289 // Those ones don't exist in backends-
1290#ifndef QT_NO_HTTP-
1291 schemes << QStringLiteral("http");
never executed: return qstring_literal_temp;
0
1292#ifndef QT_NO_SSL-
1293 if (QSslSocket::supportsSsl())
QSslSocket::supportsSsl()Description
TRUEnever evaluated
FALSEnever evaluated
0
1294 schemes << QStringLiteral("https");
never executed: schemes << ([]() -> QString { enum { Size = sizeof(u"" "https")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "https" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
1295#endif-
1296#endif-
1297 schemes << QStringLiteral("data");
never executed: return qstring_literal_temp;
0
1298 return schemes;
never executed: return schemes;
0
1299}-
1300-
1301/*!-
1302 \since 5.0-
1303-
1304 Flushes the internal cache of authentication data and network connections.-
1305-
1306 This function is useful for doing auto tests.-
1307-
1308*/-
1309void QNetworkAccessManager::clearAccessCache()-
1310{-
1311 QNetworkAccessManagerPrivate::clearCache(this);-
1312}
executed 644 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
644
1313-
1314void QNetworkAccessManagerPrivate::_q_replyFinished()-
1315{-
1316 Q_Q(QNetworkAccessManager);-
1317-
1318 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());-
1319 if (reply)
replyDescription
TRUEevaluated 931 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
FALSEnever evaluated
0-931
1320 emit q->finished(reply);
executed 931 times by 9 tests: q->finished(reply);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
931
1321-
1322#ifndef QT_NO_BEARERMANAGEMENT-
1323 // If there are no active requests, release our reference to the network session.-
1324 // It will not be destroyed immediately, but rather when the connection cache is flushed-
1325 // after 2 minutes.-
1326 activeReplyCount--;-
1327 if (networkSessionStrongRef && activeReplyCount == 0)
networkSessionStrongRefDescription
TRUEevaluated 920 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 11 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QXmlStream
activeReplyCount == 0Description
TRUEevaluated 195 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 725 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
11-920
1328 networkSessionStrongRef.clear();
executed 195 times by 7 tests: networkSessionStrongRef.clear();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
195
1329#endif-
1330}
executed 931 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
931
1331-
1332void QNetworkAccessManagerPrivate::_q_replyEncrypted()-
1333{-
1334#ifndef QT_NO_SSL-
1335 Q_Q(QNetworkAccessManager);-
1336 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());-
1337 if (reply)
replyDescription
TRUEevaluated 73 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-73
1338 emit q->encrypted(reply);
executed 73 times by 2 tests: q->encrypted(reply);
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
73
1339#endif-
1340}
executed 73 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
73
1341-
1342void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &errors)-
1343{-
1344#ifndef QT_NO_SSL-
1345 Q_Q(QNetworkAccessManager);-
1346 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());-
1347 if (reply)
replyDescription
TRUEevaluated 46 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-46
1348 emit q->sslErrors(reply, errors);
executed 46 times by 2 tests: q->sslErrors(reply, errors);
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
46
1349#else-
1350 Q_UNUSED(errors);-
1351#endif-
1352}
executed 46 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
46
1353-
1354void QNetworkAccessManagerPrivate::_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)-
1355{-
1356#ifndef QT_NO_SSL-
1357 Q_Q(QNetworkAccessManager);-
1358 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());-
1359 if (reply)
replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1360 emit q->preSharedKeyAuthenticationRequired(reply, authenticator);
never executed: q->preSharedKeyAuthenticationRequired(reply, authenticator);
0
1361#else-
1362 Q_UNUSED(authenticator);-
1363#endif-
1364}
never executed: end of block
0
1365-
1366QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply)-
1367{-
1368 Q_Q(QNetworkAccessManager);-
1369 QNetworkReplyPrivate::setManager(reply, q);-
1370 q->connect(reply, SIGNAL(finished()), SLOT(_q_replyFinished()));-
1371#ifndef QT_NO_SSL-
1372 /* In case we're compiled without SSL support, we don't have this signal and we need to-
1373 * avoid getting a connection error. */-
1374 q->connect(reply, SIGNAL(encrypted()), SLOT(_q_replyEncrypted()));-
1375 q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>)));-
1376 q->connect(reply, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), SLOT(_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)));-
1377#endif-
1378#ifndef QT_NO_BEARERMANAGEMENT-
1379 activeReplyCount++;-
1380#endif-
1381-
1382 return reply;
executed 1069 times by 10 tests: return reply;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
1069
1383}-
1384-
1385void QNetworkAccessManagerPrivate::createCookieJar() const-
1386{-
1387 if (!cookieJarCreated) {
!cookieJarCreatedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1388 // keep the ugly hack in here-
1389 QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this);-
1390 that->cookieJar = new QNetworkCookieJar(that->q_func());-
1391 that->cookieJarCreated = true;-
1392 }
never executed: end of block
0
1393}
never executed: end of block
0
1394-
1395void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authenticator,-
1396 QNetworkReply *reply,-
1397 bool synchronous,-
1398 QUrl &url,-
1399 QUrl *urlForLastAuthentication,-
1400 bool allowAuthenticationReuse)-
1401{-
1402 Q_Q(QNetworkAccessManager);-
1403-
1404 // don't try the cache for the same URL twice in a row-
1405 // being called twice for the same URL means the authentication failed-
1406 // also called when last URL is empty, e.g. on first call-
1407 if (allowAuthenticationReuse && (urlForLastAuthentication->isEmpty()
allowAuthenticationReuseDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
urlForLastAuth...ion->isEmpty()Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QNetworkReply
1-126
1408 || url != *urlForLastAuthentication)) {
url != *urlFor...AuthenticationDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-38
1409 // if credentials are included in the url, then use them-
1410 if (!url.userName().isEmpty()
!url.userName().isEmpty()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 76 times by 1 test
Evaluated by:
  • tst_QNetworkReply
12-76
1411 && !url.password().isEmpty()) {
!url.password().isEmpty()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-12
1412 authenticator->setUser(url.userName(QUrl::FullyDecoded));-
1413 authenticator->setPassword(url.password(QUrl::FullyDecoded));-
1414 *urlForLastAuthentication = url;-
1415 authenticationManager->cacheCredentials(url, authenticator);-
1416 return;
executed 12 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
12
1417 }-
1418-
1419 QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator);-
1420 if (!cred.isNull()) {
!cred.isNull()Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 56 times by 1 test
Evaluated by:
  • tst_QNetworkReply
20-56
1421 authenticator->setUser(cred.user);-
1422 authenticator->setPassword(cred.password);-
1423 *urlForLastAuthentication = url;-
1424 return;
executed 20 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
20
1425 }-
1426 }
executed 56 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
56
1427-
1428 // if we emit a signal here in synchronous mode, the user might spin-
1429 // an event loop, which might recurse and lead to problems-
1430 if (synchronous)
synchronousDescription
TRUEnever evaluated
FALSEevaluated 95 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-95
1431 return;
never executed: return;
0
1432-
1433 *urlForLastAuthentication = url;-
1434 emit q->authenticationRequired(reply, authenticator);-
1435 if (allowAuthenticationReuse)
allowAuthenticationReuseDescription
TRUEevaluated 94 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-94
1436 authenticationManager->cacheCredentials(url, authenticator);
executed 94 times by 1 test: authenticationManager->cacheCredentials(url, authenticator);
Executed by:
  • tst_QNetworkReply
94
1437}
executed 95 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
95
1438-
1439#ifndef QT_NO_NETWORKPROXY-
1440void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(const QUrl &url,-
1441 const QNetworkProxy &proxy,-
1442 bool synchronous,-
1443 QAuthenticator *authenticator,-
1444 QNetworkProxy *lastProxyAuthentication)-
1445{-
1446 Q_Q(QNetworkAccessManager);-
1447 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator);-
1448 if (proxy != *lastProxyAuthentication && (!priv || !priv->hasFailed)) {
proxy != *last...AuthenticationDescription
TRUEevaluated 66 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!privDescription
TRUEevaluated 30 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
!priv->hasFailedDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-66
1449 QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy);-
1450 if (!cred.isNull()) {
!cred.isNull()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
8-56
1451 authenticator->setUser(cred.user);-
1452 authenticator->setPassword(cred.password);-
1453 return;
executed 8 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
8
1454 }-
1455 }
executed 56 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
56
1456-
1457#if defined(Q_OS_OSX)-
1458 //now we try to get the username and password from keychain-
1459 //if not successful signal will be emitted-
1460 QString username;-
1461 QString password;-
1462 if (getProxyAuth(proxy.hostName(), url.scheme(), username, password)) {-
1463 // only cache the system credentials if they are correct (or if they have changed)-
1464 // to not run into an endless loop in case they are wrong-
1465 QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy);-
1466 if (!priv->hasFailed || cred.user != username || cred.password != password) {-
1467 authenticator->setUser(username);-
1468 authenticator->setPassword(password);-
1469 authenticationManager->cacheProxyCredentials(proxy, authenticator);-
1470 return;-
1471 }-
1472 }-
1473#else-
1474 Q_UNUSED(url);-
1475#endif-
1476-
1477 // if we emit a signal here in synchronous mode, the user might spin-
1478 // an event loop, which might recurse and lead to problems-
1479 if (synchronous)
synchronousDescription
TRUEnever evaluated
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
0-60
1480 return;
never executed: return;
0
1481-
1482 *lastProxyAuthentication = proxy;-
1483 emit q->proxyAuthenticationRequired(proxy, authenticator);-
1484 authenticationManager->cacheProxyCredentials(proxy, authenticator);-
1485}
executed 60 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
60
1486-
1487QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProxyQuery &query)-
1488{-
1489 QList<QNetworkProxy> proxies;-
1490 if (proxyFactory) {
proxyFactoryDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 986 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
20-986
1491 proxies = proxyFactory->queryProxy(query);-
1492 if (proxies.isEmpty()) {
proxies.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-20
1493 qWarning("QNetworkAccessManager: factory %p has returned an empty result set",-
1494 proxyFactory);-
1495 proxies << QNetworkProxy::NoProxy;-
1496 }
never executed: end of block
0
1497 } else if (proxy.type() == QNetworkProxy::DefaultProxy) {
executed 20 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
proxy.type() =...::DefaultProxyDescription
TRUEevaluated 832 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 154 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
20-832
1498 // no proxy set, query the application-
1499 return QNetworkProxyFactory::proxyForQuery(query);
executed 832 times by 8 tests: return QNetworkProxyFactory::proxyForQuery(query);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
832
1500 } else {-
1501 proxies << proxy;-
1502 }
executed 154 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
154
1503-
1504 return proxies;
executed 174 times by 2 tests: return proxies;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
174
1505}-
1506#endif-
1507-
1508void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager)-
1509{-
1510 manager->d_func()->objectCache.clear();-
1511 manager->d_func()->authenticationManager->clearCache();-
1512-
1513 if (manager->d_func()->httpThread) {
manager->d_func()->httpThreadDescription
TRUEevaluated 394 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 252 times by 1 test
Evaluated by:
  • tst_QNetworkReply
252-394
1514 manager->d_func()->httpThread->quit();-
1515 manager->d_func()->httpThread->wait(5000);-
1516 if (manager->d_func()->httpThread->isFinished())
manager->d_fun...->isFinished()Description
TRUEevaluated 394 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-394
1517 delete manager->d_func()->httpThread;
executed 394 times by 2 tests: delete manager->d_func()->httpThread;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
394
1518 else-
1519 QObject::connect(manager->d_func()->httpThread, SIGNAL(finished()), manager->d_func()->httpThread, SLOT(deleteLater()));
never executed: QObject::connect(manager->d_func()->httpThread, qFlagLocation("2""finished()" "\0" __FILE__ ":" "1519"), manager->d_func()->httpThread, qFlagLocation("1""deleteLater()" "\0" __FILE__ ":" "1519"));
0
1520 manager->d_func()->httpThread = 0;-
1521 }
executed 394 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
394
1522}
executed 646 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
646
1523-
1524QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()-
1525{-
1526 if (httpThread) {
httpThreadDescription
TRUEevaluated 76 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_spdy - unknown status
FALSEevaluated 16 times by 4 tests
Evaluated by:
  • tst_QNetworkAccessManager
  • tst_QNetworkConfigurationManager
  • tst_QNetworkReply
  • tst_QXmlStream
16-76
1527 httpThread->quit();-
1528 httpThread->wait(5000);-
1529 if (httpThread->isFinished())
httpThread->isFinished()Description
TRUEevaluated 76 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_spdy - unknown status
FALSEnever evaluated
0-76
1530 delete httpThread;
executed 76 times by 8 tests: delete httpThread;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_spdy - unknown status
76
1531 else-
1532 QObject::connect(httpThread, SIGNAL(finished()), httpThread, SLOT(deleteLater()));
never executed: QObject::connect(httpThread, qFlagLocation("2""finished()" "\0" __FILE__ ":" "1532"), httpThread, qFlagLocation("1""deleteLater()" "\0" __FILE__ ":" "1532"));
0
1533 httpThread = 0;-
1534 }
executed 76 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_spdy - unknown status
76
1535}
executed 92 times by 11 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_spdy - unknown status
92
1536-
1537#ifndef QT_NO_BEARERMANAGEMENT-
1538void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &config)-
1539{-
1540 Q_Q(QNetworkAccessManager);-
1541-
1542 initializeSession = false;-
1543-
1544 //resurrect weak ref if possible-
1545 networkSessionStrongRef = networkSessionWeakRef.toStrongRef();-
1546-
1547 QSharedPointer<QNetworkSession> newSession;-
1548 if (config.isValid())
config.isValid()Description
TRUEevaluated 222 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-222
1549 newSession = QSharedNetworkSessionManager::getSession(config);
executed 222 times by 9 tests: newSession = QSharedNetworkSessionManager::getSession(config);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
222
1550-
1551 if (networkSessionStrongRef) {
networkSessionStrongRefDescription
TRUEevaluated 123 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99-123
1552 //do nothing if new and old session are the same-
1553 if (networkSessionStrongRef == newSession)
networkSession... == newSessionDescription
TRUEevaluated 123 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-123
1554 return;
executed 123 times by 3 tests: return;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
123
1555 //disconnect from old session-
1556 QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));-
1557 QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));-
1558 QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)),-
1559 q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));-
1560 QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)),-
1561 q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError)));-
1562 }
never executed: end of block
0
1563-
1564 //switch to new session (null if config was invalid)-
1565 networkSessionStrongRef = newSession;-
1566 networkSessionWeakRef = networkSessionStrongRef.toWeakRef();-
1567-
1568 if (!networkSessionStrongRef) {
!networkSessionStrongRefDescription
TRUEnever evaluated
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-99
1569-
1570 if (networkAccessible == QNetworkAccessManager::NotAccessible || !online)
networkAccessi...:NotAccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
!onlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1571 emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
never executed: q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
0
1572 else-
1573 emit q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility);
never executed: q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility);
0
1574-
1575 return;
never executed: return;
0
1576 }-
1577-
1578 //connect to new session-
1579 QObject::connect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()), Qt::QueuedConnection);-
1580 //QueuedConnection is used to avoid deleting the networkSession inside its closed signal-
1581 QObject::connect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection);-
1582 QObject::connect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)),-
1583 q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);-
1584 QObject::connect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)),-
1585 q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError)));-
1586-
1587 _q_networkSessionStateChanged(networkSessionStrongRef->state());-
1588}
executed 99 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99
1589-
1590void QNetworkAccessManagerPrivate::_q_networkSessionClosed()-
1591{-
1592 Q_Q(QNetworkAccessManager);-
1593 QSharedPointer<QNetworkSession> networkSession(getNetworkSession());-
1594 if (networkSession) {
networkSessionDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-4
1595 networkConfiguration = networkSession->configuration();-
1596-
1597 //disconnect from old session-
1598 QObject::disconnect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));-
1599 QObject::disconnect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));-
1600 QObject::disconnect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)),-
1601 q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));-
1602 QObject::disconnect(networkSession.data(), SIGNAL(error(QNetworkSession::SessionError)),-
1603 q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError)));-
1604-
1605 networkSessionStrongRef.clear();-
1606 networkSessionWeakRef.clear();-
1607 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
4
1608}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
4
1609-
1610void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state)-
1611{-
1612 Q_Q(QNetworkAccessManager);-
1613 bool reallyOnline = false;-
1614 //Do not emit the networkSessionConnected signal here, except for roaming -> connected-
1615 //transition, otherwise it is emitted twice in a row when opening a connection.-
1616 if (state == QNetworkSession::Connected && lastSessionState != QNetworkSession::Roaming)
state == QNetw...ion::ConnectedDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
lastSessionSta...ssion::RoamingDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-99
1617 emit q->networkSessionConnected();
executed 99 times by 9 tests: q->networkSessionConnected();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99
1618 lastSessionState = state;-
1619-
1620 if (online && state == QNetworkSession::Disconnected) {
onlineDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
state == QNetw...::DisconnectedDescription
TRUEnever evaluated
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-99
1621 Q_FOREACH (const QNetworkConfiguration &cfg, networkConfigurationManager.allConfigurations()) {-
1622 if (cfg.state().testFlag(QNetworkConfiguration::Active)) {
cfg.state().te...ation::Active)Description
TRUEnever evaluated
FALSEnever evaluated
0
1623 reallyOnline = true;-
1624 }
never executed: end of block
0
1625 }
never executed: end of block
0
1626 } else if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) {
never executed: end of block
state == QNetw...ion::ConnectedDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
state == QNetw...ssion::RoamingDescription
TRUEnever evaluated
FALSEnever evaluated
0-99
1627 reallyOnline = true;-
1628 }
executed 99 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99
1629-
1630 if (!reallyOnline) {
!reallyOnlineDescription
TRUEnever evaluated
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-99
1631 if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) {
state != QNetw...ion::ConnectedDescription
TRUEnever evaluated
FALSEnever evaluated
state != QNetw...ssion::RoamingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1632 if (networkAccessible != QNetworkAccessManager::NotAccessible) {
networkAccessi...:NotAccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1633 networkAccessible = QNetworkAccessManager::NotAccessible;-
1634 emit q->networkAccessibleChanged(networkAccessible);-
1635 }
never executed: end of block
0
1636 }
never executed: end of block
0
1637 } else {
never executed: end of block
0
1638 if (defaultAccessControl)
defaultAccessControlDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-99
1639 if (networkAccessible != QNetworkAccessManager::Accessible) {
networkAccessi...er::AccessibleDescription
TRUEnever evaluated
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-99
1640 networkAccessible = QNetworkAccessManager::Accessible;-
1641 emit q->networkAccessibleChanged(networkAccessible);-
1642 }
never executed: end of block
0
1643 }
executed 99 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99
1644 online = reallyOnline;-
1645 if (online && (state != QNetworkSession::Connected && state != QNetworkSession::Roaming)) {
onlineDescription
TRUEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
state != QNetw...ion::ConnectedDescription
TRUEnever evaluated
FALSEevaluated 99 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
state != QNetw...ssion::RoamingDescription
TRUEnever evaluated
FALSEnever evaluated
0-99
1646 _q_networkSessionClosed();-
1647 createSession(q->configuration());-
1648 }
never executed: end of block
0
1649}
executed 99 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
99
1650-
1651void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline)-
1652{-
1653 Q_Q(QNetworkAccessManager);-
1654-
1655 // if the user set a config, we only care whether this one is active.-
1656 // Otherwise, this QNAM is online if there is an online config.-
1657 if (customNetworkConfiguration) {
customNetworkConfigurationDescription
TRUEnever evaluated
FALSEnever evaluated
0
1658 online = (networkConfiguration.state() & QNetworkConfiguration::Active);-
1659 } else {
never executed: end of block
0
1660 if (online != isOnline) {
online != isOnlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1661 _q_networkSessionClosed();-
1662 createSession(q->configuration());-
1663 online = isOnline;-
1664 }
never executed: end of block
0
1665 }
never executed: end of block
0
1666 if (online) {
onlineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1667 if (defaultAccessControl) {
defaultAccessControlDescription
TRUEnever evaluated
FALSEnever evaluated
0
1668 if (networkAccessible != QNetworkAccessManager::Accessible) {
networkAccessi...er::AccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1669 networkAccessible = QNetworkAccessManager::Accessible;-
1670 emit q->networkAccessibleChanged(networkAccessible);-
1671 }
never executed: end of block
0
1672 }
never executed: end of block
0
1673 } else {
never executed: end of block
0
1674 if (networkAccessible != QNetworkAccessManager::NotAccessible) {
networkAccessi...:NotAccessibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1675 networkAccessible = QNetworkAccessManager::NotAccessible;-
1676 emit q->networkAccessibleChanged(networkAccessible);-
1677 }
never executed: end of block
0
1678 }
never executed: end of block
0
1679}-
1680-
1681void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfiguration &configuration)-
1682{-
1683 const QString id = configuration.identifier();-
1684 if (configuration.state().testFlag(QNetworkConfiguration::Active)) {
configuration....ation::Active)Description
TRUEnever evaluated
FALSEnever evaluated
0
1685 if (!onlineConfigurations.contains(id)) {
!onlineConfigu...s.contains(id)Description
TRUEnever evaluated
FALSEnever evaluated
0
1686-
1687 QSharedPointer<QNetworkSession> session(getNetworkSession());-
1688 if (session) {
sessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
1689 if (online && session->configuration().identifier()
onlineDescription
TRUEnever evaluated
FALSEnever evaluated
session->confi...).identifier()Description
TRUEnever evaluated
FALSEnever evaluated
0
1690 != networkConfigurationManager.defaultConfiguration().identifier()) {
session->confi...).identifier()Description
TRUEnever evaluated
FALSEnever evaluated
0
1691-
1692 onlineConfigurations.insert(id);-
1693 //this one disconnected but another one is online,-
1694 // close and create new session-
1695 _q_networkSessionClosed();-
1696 createSession(networkConfigurationManager.defaultConfiguration());-
1697 }
never executed: end of block
0
1698 }
never executed: end of block
0
1699 }
never executed: end of block
0
1700-
1701 } else if (onlineConfigurations.contains(id)) {
never executed: end of block
onlineConfigur...s.contains(id)Description
TRUEnever evaluated
FALSEnever evaluated
0
1702 //this one is disconnecting-
1703 onlineConfigurations.remove(id);-
1704 if (!onlineConfigurations.isEmpty()) {
!onlineConfigu...ions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1705 _q_networkSessionClosed();-
1706 createSession(configuration);-
1707 }
never executed: end of block
0
1708 }
never executed: end of block
0
1709}
never executed: end of block
0
1710-
1711-
1712void QNetworkAccessManagerPrivate::_q_networkSessionFailed(QNetworkSession::SessionError)-
1713{-
1714 Q_FOREACH (const QNetworkConfiguration &cfg, networkConfigurationManager.allConfigurations()) {-
1715 if (cfg.state().testFlag(QNetworkConfiguration::Active)) {
cfg.state().te...ation::Active)Description
TRUEnever evaluated
FALSEnever evaluated
0
1716 online = true;-
1717 _q_networkSessionClosed();-
1718 createSession(networkConfigurationManager.defaultConfiguration());-
1719 return;
never executed: return;
0
1720 }-
1721 }
never executed: end of block
0
1722}
never executed: end of block
0
1723-
1724#endif // QT_NO_BEARERMANAGEMENT-
1725-
1726QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart)-
1727{-
1728 // copy the request, we probably need to add some headers-
1729 QNetworkRequest newRequest(request);-
1730-
1731 // add Content-Type header if not there already-
1732 if (!request.header(QNetworkRequest::ContentTypeHeader).isValid()) {
!request.heade...der).isValid()Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-22
1733 QByteArray contentType;-
1734 contentType.reserve(34 + multiPart->d_func()->boundary.count());-
1735 contentType += "multipart/";-
1736 switch (multiPart->d_func()->contentType) {-
1737 case QHttpMultiPart::RelatedType:
executed 2 times by 1 test: case QHttpMultiPart::RelatedType:
Executed by:
  • tst_QNetworkReply
2
1738 contentType += "related";-
1739 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
2
1740 case QHttpMultiPart::FormDataType:
executed 13 times by 2 tests: case QHttpMultiPart::FormDataType:
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
13
1741 contentType += "form-data";-
1742 break;
executed 13 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
13
1743 case QHttpMultiPart::AlternativeType:
executed 4 times by 1 test: case QHttpMultiPart::AlternativeType:
Executed by:
  • tst_QNetworkReply
4
1744 contentType += "alternative";-
1745 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
4
1746 default:
executed 3 times by 1 test: default:
Executed by:
  • tst_QNetworkReply
3
1747 contentType += "mixed";-
1748 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
3
1749 }-
1750 // putting the boundary into quotes, recommended in RFC 2046 section 5.1.1-
1751 contentType += "; boundary=\"" + multiPart->d_func()->boundary + '"';-
1752 newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(contentType));-
1753 }
executed 22 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
22
1754-
1755 // add MIME-Version header if not there already (we must include the header-
1756 // if the message conforms to RFC 2045, see section 4 of that RFC)-
1757 QByteArray mimeHeader("MIME-Version");-
1758 if (!request.hasRawHeader(mimeHeader))
!request.hasRa...er(mimeHeader)Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-24
1759 newRequest.setRawHeader(mimeHeader, QByteArray("1.0"));
executed 24 times by 2 tests: newRequest.setRawHeader(mimeHeader, QByteArray("1.0"));
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
24
1760-
1761 QIODevice *device = multiPart->d_func()->device;-
1762 if (!device->isReadable()) {
!device->isReadable()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-24
1763 if (!device->isOpen()) {
!device->isOpen()Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-24
1764 if (!device->open(QIODevice::ReadOnly))
!device->open(...ice::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
0-24
1765 qWarning("could not open device for reading");
never executed: QMessageLogger(__FILE__, 1765, __PRETTY_FUNCTION__).warning("could not open device for reading");
0
1766 } else {
executed 24 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
24
1767 qWarning("device is not readable");-
1768 }
never executed: end of block
0
1769 }-
1770-
1771 return newRequest;
executed 24 times by 2 tests: return newRequest;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
24
1772}-
1773-
1774QT_END_NAMESPACE-
1775-
1776#include "moc_qnetworkaccessmanager.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9