Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qnetworkaccessmanager.h" | - |
43 | #include "qnetworkaccessmanager_p.h" | - |
44 | #include "qnetworkrequest.h" | - |
45 | #include "qnetworkreply.h" | - |
46 | #include "qnetworkreply_p.h" | - |
47 | #include "qnetworkcookie.h" | - |
48 | #include "qnetworkcookiejar.h" | - |
49 | #include "qabstractnetworkcache.h" | - |
50 | | - |
51 | #include "QtNetwork/qnetworksession.h" | - |
52 | #include "QtNetwork/private/qsharednetworksession_p.h" | - |
53 | | - |
54 | #include "qnetworkaccessftpbackend_p.h" | - |
55 | #include "qnetworkaccessfilebackend_p.h" | - |
56 | #include "qnetworkaccessdebugpipebackend_p.h" | - |
57 | #include "qnetworkaccesscachebackend_p.h" | - |
58 | #include "qnetworkreplydataimpl_p.h" | - |
59 | #include "qnetworkreplyfileimpl_p.h" | - |
60 | | - |
61 | #include "QtCore/qbuffer.h" | - |
62 | #include "QtCore/qurl.h" | - |
63 | #include "QtCore/qvector.h" | - |
64 | #include "QtNetwork/private/qauthenticator_p.h" | - |
65 | #include "QtNetwork/qsslconfiguration.h" | - |
66 | #include "QtNetwork/qnetworkconfigmanager.h" | - |
67 | #include "QtNetwork/qhttpmultipart.h" | - |
68 | #include "qhttpmultipart_p.h" | - |
69 | | - |
70 | #include "qnetworkreplyhttpimpl_p.h" | - |
71 | | - |
72 | #include "qthread.h" | - |
73 | | - |
74 | QT_BEGIN_NAMESPACE | - |
75 | | - |
76 | Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:85 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:8 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:8 | yes Evaluation Count:77 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-85 |
77 | #ifndef QT_NO_FTP | - |
78 | Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:85 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:8 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:8 | yes Evaluation Count:77 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-85 |
79 | #endif // QT_NO_FTP | - |
80 | | - |
81 | #ifdef QT_BUILD_INTERNAL | - |
82 | Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend) | - |
83 | #endif | - |
84 | | - |
85 | #if defined(Q_OS_MAC) && !defined(Q_OS_IOS) | - |
86 | | - |
87 | #include <CoreServices/CoreServices.h> | - |
88 | #include <SystemConfiguration/SystemConfiguration.h> | - |
89 | #include <Security/SecKeychain.h> | - |
90 | | - |
91 | bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& username, QString& password) | - |
92 | { | - |
93 | OSStatus err; | - |
94 | SecKeychainItemRef itemRef; | - |
95 | bool retValue = false; | - |
96 | SecProtocolType protocolType = kSecProtocolTypeAny; | - |
97 | if (scheme.compare(QLatin1String("ftp"),Qt::CaseInsensitive)==0) { | - |
98 | protocolType = kSecProtocolTypeFTP; | - |
99 | } else if (scheme.compare(QLatin1String("http"),Qt::CaseInsensitive)==0) { | - |
100 | protocolType = kSecProtocolTypeHTTP; | - |
101 | } else if (scheme.compare(QLatin1String("https"),Qt::CaseInsensitive)==0) { | - |
102 | protocolType = kSecProtocolTypeHTTPS; | - |
103 | } | - |
104 | QByteArray proxyHostnameUtf8(proxyHostname.toUtf8()); | - |
105 | err = SecKeychainFindInternetPassword(NULL, | - |
106 | proxyHostnameUtf8.length(), proxyHostnameUtf8.constData(), | - |
107 | 0,NULL, | - |
108 | 0, NULL, | - |
109 | 0, NULL, | - |
110 | 0, | - |
111 | protocolType, | - |
112 | kSecAuthenticationTypeAny, | - |
113 | 0, NULL, | - |
114 | &itemRef); | - |
115 | if (err == noErr) { | - |
116 | | - |
117 | SecKeychainAttribute attr; | - |
118 | SecKeychainAttributeList attrList; | - |
119 | UInt32 length; | - |
120 | void *outData; | - |
121 | | - |
122 | attr.tag = kSecAccountItemAttr; | - |
123 | attr.length = 0; | - |
124 | attr.data = NULL; | - |
125 | | - |
126 | attrList.count = 1; | - |
127 | attrList.attr = &attr; | - |
128 | | - |
129 | if (SecKeychainItemCopyContent(itemRef, NULL, &attrList, &length, &outData) == noErr) { | - |
130 | username = QString::fromUtf8((const char*)attr.data, attr.length); | - |
131 | password = QString::fromUtf8((const char*)outData, length); | - |
132 | SecKeychainItemFreeContent(&attrList,outData); | - |
133 | retValue = true; | - |
134 | } | - |
135 | CFRelease(itemRef); | - |
136 | } | - |
137 | return retValue; | - |
138 | } | - |
139 | #endif | - |
140 | | - |
141 | | - |
142 | | - |
143 | static void ensureInitialized() | - |
144 | { | - |
145 | #ifndef QT_NO_FTP | - |
146 | (void) ftpBackend(); executed (the execution status of this line is deduced): (void) ftpBackend(); | - |
147 | #endif | - |
148 | | - |
149 | #ifdef QT_BUILD_INTERNAL | - |
150 | (void) debugpipeBackend(); | - |
151 | #endif | - |
152 | | - |
153 | // leave this one last since it will query the special QAbstractFileEngines | - |
154 | (void) fileBackend(); executed (the execution status of this line is deduced): (void) fileBackend(); | - |
155 | } executed: } Execution Count:85 | 85 |
156 | | - |
157 | /*! | - |
158 | \class QNetworkAccessManager | - |
159 | \brief The QNetworkAccessManager class allows the application to | - |
160 | send network requests and receive replies | - |
161 | \since 4.4 | - |
162 | | - |
163 | \ingroup network | - |
164 | \inmodule QtNetwork | - |
165 | \reentrant | - |
166 | | - |
167 | The Network Access API is constructed around one QNetworkAccessManager | - |
168 | object, which holds the common configuration and settings for the requests | - |
169 | it sends. It contains the proxy and cache configuration, as well as the | - |
170 | signals related to such issues, and reply signals that can be used to | - |
171 | monitor the progress of a network operation. One QNetworkAccessManager | - |
172 | should be enough for the whole Qt application. | - |
173 | | - |
174 | Once a QNetworkAccessManager object has been created, the application can | - |
175 | use it to send requests over the network. A group of standard functions | - |
176 | are supplied that take a request and optional data, and each return a | - |
177 | QNetworkReply object. The returned object is used to obtain any data | - |
178 | returned in response to the corresponding request. | - |
179 | | - |
180 | A simple download off the network could be accomplished with: | - |
181 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 0 | - |
182 | | - |
183 | QNetworkAccessManager has an asynchronous API. | - |
184 | When the \tt replyFinished slot above is called, the parameter it | - |
185 | takes is the QNetworkReply object containing the downloaded data | - |
186 | as well as meta-data (headers, etc.). | - |
187 | | - |
188 | \note After the request has finished, it is the responsibility of the user | - |
189 | to delete the QNetworkReply object at an appropriate time. Do not directly | - |
190 | delete it inside the slot connected to finished(). You can use the | - |
191 | deleteLater() function. | - |
192 | | - |
193 | \note QNetworkAccessManager queues the requests it receives. The number | - |
194 | of requests executed in parallel is dependent on the protocol. | - |
195 | Currently, for the HTTP protocol on desktop platforms, 6 requests are | - |
196 | executed in parallel for one host/port combination. | - |
197 | | - |
198 | A more involved example, assuming the manager is already existent, | - |
199 | can be: | - |
200 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 1 | - |
201 | | - |
202 | \section1 Network and Roaming support | - |
203 | | - |
204 | With the addition of the \l {Bearer Management} API to Qt 4.7 | - |
205 | QNetworkAccessManager gained the ability to manage network connections. | - |
206 | QNetworkAccessManager can start the network interface if the device is | - |
207 | offline and terminates the interface if the current process is the last | - |
208 | one to use the uplink. Note that some platforms utilize grace periods from | - |
209 | when the last application stops using a uplink until the system actually | - |
210 | terminates the connectivity link. Roaming is equally transparent. Any | - |
211 | queued/pending network requests are automatically transferred to the new | - |
212 | access point. | - |
213 | | - |
214 | Clients wanting to utilize this feature should not require any changes. In fact | - |
215 | it is likely that existing platform specific connection code can simply be | - |
216 | removed from the application. | - |
217 | | - |
218 | \note The network and roaming support in QNetworkAccessManager is conditional | - |
219 | upon the platform supporting connection management. The | - |
220 | \l QNetworkConfigurationManager::NetworkSessionRequired can be used to | - |
221 | detect whether QNetworkAccessManager utilizes this feature. Currently only | - |
222 | Meego/Harmattan platforms provide connection management support. | - |
223 | | - |
224 | \note This feature cannot be used in combination with the Bearer Management | - |
225 | API as provided by QtMobility. Applications have to migrate to the Qt version | - |
226 | of Bearer Management. | - |
227 | | - |
228 | \sa QNetworkRequest, QNetworkReply, QNetworkProxy | - |
229 | */ | - |
230 | | - |
231 | /*! | - |
232 | \enum QNetworkAccessManager::Operation | - |
233 | | - |
234 | Indicates the operation this reply is processing. | - |
235 | | - |
236 | \value HeadOperation retrieve headers operation (created | - |
237 | with head()) | - |
238 | | - |
239 | \value GetOperation retrieve headers and download contents | - |
240 | (created with get()) | - |
241 | | - |
242 | \value PutOperation upload contents operation (created | - |
243 | with put()) | - |
244 | | - |
245 | \value PostOperation send the contents of an HTML form for | - |
246 | processing via HTTP POST (created with post()) | - |
247 | | - |
248 | \value DeleteOperation delete contents operation (created with | - |
249 | deleteResource()) | - |
250 | | - |
251 | \value CustomOperation custom operation (created with | - |
252 | sendCustomRequest()) \since 4.7 | - |
253 | | - |
254 | \omitvalue UnknownOperation | - |
255 | | - |
256 | \sa QNetworkReply::operation() | - |
257 | */ | - |
258 | | - |
259 | /*! | - |
260 | \enum QNetworkAccessManager::NetworkAccessibility | - |
261 | | - |
262 | Indicates whether the network is accessible via this network access manager. | - |
263 | | - |
264 | \value UnknownAccessibility The network accessibility cannot be determined. | - |
265 | \value NotAccessible The network is not currently accessible, either because there | - |
266 | is currently no network coverage or network access has been | - |
267 | explicitly disabled by a call to setNetworkAccessible(). | - |
268 | \value Accessible The network is accessible. | - |
269 | | - |
270 | \sa networkAccessible | - |
271 | */ | - |
272 | | - |
273 | /*! | - |
274 | \property QNetworkAccessManager::networkAccessible | - |
275 | \brief whether the network is currently accessible via this network access manager. | - |
276 | | - |
277 | \since 4.7 | - |
278 | | - |
279 | If the network is \l {NotAccessible}{not accessible} the network access manager will not | - |
280 | process any new network requests, all such requests will fail with an error. Requests with | - |
281 | URLs with the file:// scheme will still be processed. | - |
282 | | - |
283 | By default the value of this property reflects the physical state of the device. Applications | - |
284 | may override it to disable all network requests via this network access manager by calling | - |
285 | | - |
286 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 4 | - |
287 | | - |
288 | Network requests can be reenabled again by calling | - |
289 | | - |
290 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 5 | - |
291 | | - |
292 | \note Calling setNetworkAccessible() does not change the network state. | - |
293 | */ | - |
294 | | - |
295 | /*! | - |
296 | \fn void QNetworkAccessManager::networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible) | - |
297 | | - |
298 | This signal is emitted when the value of the \l networkAccessible property changes. | - |
299 | \a accessible is the new network accessibility. | - |
300 | */ | - |
301 | | - |
302 | /*! | - |
303 | \fn void QNetworkAccessManager::networkSessionConnected() | - |
304 | | - |
305 | \since 4.7 | - |
306 | | - |
307 | \internal | - |
308 | | - |
309 | This signal is emitted when the status of the network session changes into a usable (Connected) | - |
310 | state. It is used to signal to QNetworkReplys to start or migrate their network operation once | - |
311 | the network session has been opened or finished roaming. | - |
312 | */ | - |
313 | | - |
314 | /*! | - |
315 | \fn void QNetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) | - |
316 | | - |
317 | This signal is emitted whenever a proxy requests authentication | - |
318 | and QNetworkAccessManager cannot find a valid, cached | - |
319 | credential. The slot connected to this signal should fill in the | - |
320 | credentials for the proxy \a proxy in the \a authenticator object. | - |
321 | | - |
322 | QNetworkAccessManager will cache the credentials internally. The | - |
323 | next time the proxy requests authentication, QNetworkAccessManager | - |
324 | will automatically send the same credential without emitting the | - |
325 | proxyAuthenticationRequired signal again. | - |
326 | | - |
327 | If the proxy rejects the credentials, QNetworkAccessManager will | - |
328 | emit the signal again. | - |
329 | | - |
330 | \sa proxy(), setProxy(), authenticationRequired() | - |
331 | */ | - |
332 | | - |
333 | /*! | - |
334 | \fn void QNetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator) | - |
335 | | - |
336 | This signal is emitted whenever a final server requests | - |
337 | authentication before it delivers the requested contents. The slot | - |
338 | connected to this signal should fill the credentials for the | - |
339 | contents (which can be determined by inspecting the \a reply | - |
340 | object) in the \a authenticator object. | - |
341 | | - |
342 | QNetworkAccessManager will cache the credentials internally and | - |
343 | will send the same values if the server requires authentication | - |
344 | again, without emitting the authenticationRequired() signal. If it | - |
345 | rejects the credentials, this signal will be emitted again. | - |
346 | | - |
347 | \note To have the request not send credentials you must not call | - |
348 | setUser() or setPassword() on the \a authenticator object. This | - |
349 | will result in the \l finished() signal being emitted with a | - |
350 | \l QNetworkReply with error \l {QNetworkReply::} {AuthenticationRequiredError}. | - |
351 | | - |
352 | \note It is not possible to use a QueuedConnection to connect to | - |
353 | this signal, as the connection will fail if the authenticator has | - |
354 | not been filled in with new information when the signal returns. | - |
355 | | - |
356 | \sa proxyAuthenticationRequired(), QAuthenticator::setUser(), QAuthenticator::setPassword() | - |
357 | */ | - |
358 | | - |
359 | /*! | - |
360 | \fn void QNetworkAccessManager::finished(QNetworkReply *reply) | - |
361 | | - |
362 | This signal is emitted whenever a pending network reply is | - |
363 | finished. The \a reply parameter will contain a pointer to the | - |
364 | reply that has just finished. This signal is emitted in tandem | - |
365 | with the QNetworkReply::finished() signal. | - |
366 | | - |
367 | See QNetworkReply::finished() for information on the status that | - |
368 | the object will be in. | - |
369 | | - |
370 | \note Do not delete the \a reply object in the slot connected to this | - |
371 | signal. Use deleteLater(). | - |
372 | | - |
373 | \sa QNetworkReply::finished(), QNetworkReply::error() | - |
374 | */ | - |
375 | | - |
376 | /*! | - |
377 | \fn void QNetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &errors) | - |
378 | | - |
379 | This signal is emitted if the SSL/TLS session encountered errors | - |
380 | during the set up, including certificate verification errors. The | - |
381 | \a errors parameter contains the list of errors and \a reply is | - |
382 | the QNetworkReply that is encountering these errors. | - |
383 | | - |
384 | To indicate that the errors are not fatal and that the connection | - |
385 | should proceed, the QNetworkReply::ignoreSslErrors() function should be called | - |
386 | from the slot connected to this signal. If it is not called, the | - |
387 | SSL session will be torn down before any data is exchanged | - |
388 | (including the URL). | - |
389 | | - |
390 | This signal can be used to display an error message to the user | - |
391 | indicating that security may be compromised and display the | - |
392 | SSL settings (see sslConfiguration() to obtain it). If the user | - |
393 | decides to proceed after analyzing the remote certificate, the | - |
394 | slot should call ignoreSslErrors(). | - |
395 | | - |
396 | \sa QSslSocket::sslErrors(), QNetworkReply::sslErrors(), | - |
397 | QNetworkReply::sslConfiguration(), QNetworkReply::ignoreSslErrors() | - |
398 | */ | - |
399 | | - |
400 | | - |
401 | /*! | - |
402 | Constructs a QNetworkAccessManager object that is the center of | - |
403 | the Network Access API and sets \a parent as the parent object. | - |
404 | */ | - |
405 | QNetworkAccessManager::QNetworkAccessManager(QObject *parent) | - |
406 | : QObject(*new QNetworkAccessManagerPrivate, parent) | - |
407 | { | - |
408 | ensureInitialized(); executed (the execution status of this line is deduced): ensureInitialized(); | - |
409 | | - |
410 | qRegisterMetaType<QNetworkReply::NetworkError>(); executed (the execution status of this line is deduced): qRegisterMetaType<QNetworkReply::NetworkError>(); | - |
411 | #ifndef QT_NO_NETWORKPROXY | - |
412 | qRegisterMetaType<QNetworkProxy>(); executed (the execution status of this line is deduced): qRegisterMetaType<QNetworkProxy>(); | - |
413 | #endif | - |
414 | #ifndef QT_NO_SSL | - |
415 | qRegisterMetaType<QList<QSslError> >(); executed (the execution status of this line is deduced): qRegisterMetaType<QList<QSslError> >(); | - |
416 | qRegisterMetaType<QSslConfiguration>(); executed (the execution status of this line is deduced): qRegisterMetaType<QSslConfiguration>(); | - |
417 | #endif | - |
418 | qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >(); executed (the execution status of this line is deduced): qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >(); | - |
419 | #ifndef QT_NO_HTTP | - |
420 | qRegisterMetaType<QHttpNetworkRequest>(); executed (the execution status of this line is deduced): qRegisterMetaType<QHttpNetworkRequest>(); | - |
421 | #endif | - |
422 | qRegisterMetaType<QNetworkReply::NetworkError>(); executed (the execution status of this line is deduced): qRegisterMetaType<QNetworkReply::NetworkError>(); | - |
423 | qRegisterMetaType<QSharedPointer<char> >(); executed (the execution status of this line is deduced): qRegisterMetaType<QSharedPointer<char> >(); | - |
424 | } executed: } Execution Count:85 | 85 |
425 | | - |
426 | /*! | - |
427 | Destroys the QNetworkAccessManager object and frees up any | - |
428 | resources. Note that QNetworkReply objects that are returned from | - |
429 | this class have this object set as their parents, which means that | - |
430 | they will be deleted along with it if you don't call | - |
431 | QObject::setParent() on them. | - |
432 | */ | - |
433 | QNetworkAccessManager::~QNetworkAccessManager() | - |
434 | { | - |
435 | #ifndef QT_NO_NETWORKPROXY | - |
436 | delete d_func()->proxyFactory; executed (the execution status of this line is deduced): delete d_func()->proxyFactory; | - |
437 | #endif | - |
438 | | - |
439 | // Delete the QNetworkReply children first. | - |
440 | // Else a QAbstractNetworkCache might get deleted in ~QObject | - |
441 | // before a QNetworkReply that accesses the QAbstractNetworkCache | - |
442 | // object in its destructor. | - |
443 | qDeleteAll(findChildren<QNetworkReply *>()); executed (the execution status of this line is deduced): qDeleteAll(findChildren<QNetworkReply *>()); | - |
444 | // The other children will be deleted in this ~QObject | - |
445 | // FIXME instead of this "hack" make the QNetworkReplyImpl | - |
446 | // properly watch the cache deletion, e.g. via a QWeakPointer. | - |
447 | } executed: } Execution Count:85 | 85 |
448 | | - |
449 | #ifndef QT_NO_NETWORKPROXY | - |
450 | /*! | - |
451 | Returns the QNetworkProxy that the requests sent using this | - |
452 | QNetworkAccessManager object will use. The default value for the | - |
453 | proxy is QNetworkProxy::DefaultProxy. | - |
454 | | - |
455 | \sa setProxy(), setProxyFactory(), proxyAuthenticationRequired() | - |
456 | */ | - |
457 | QNetworkProxy QNetworkAccessManager::proxy() const | - |
458 | { | - |
459 | return d_func()->proxy; never executed: return d_func()->proxy; | 0 |
460 | } | - |
461 | | - |
462 | /*! | - |
463 | Sets the proxy to be used in future requests to be \a proxy. This | - |
464 | does not affect requests that have already been sent. The | - |
465 | proxyAuthenticationRequired() signal will be emitted if the proxy | - |
466 | requests authentication. | - |
467 | | - |
468 | A proxy set with this function will be used for all requests | - |
469 | issued by QNetworkAccessManager. In some cases, it might be | - |
470 | necessary to select different proxies depending on the type of | - |
471 | request being sent or the destination host. If that's the case, | - |
472 | you should consider using setProxyFactory(). | - |
473 | | - |
474 | \sa proxy(), proxyAuthenticationRequired() | - |
475 | */ | - |
476 | void QNetworkAccessManager::setProxy(const QNetworkProxy &proxy) | - |
477 | { | - |
478 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
479 | delete d->proxyFactory; executed (the execution status of this line is deduced): delete d->proxyFactory; | - |
480 | d->proxy = proxy; executed (the execution status of this line is deduced): d->proxy = proxy; | - |
481 | d->proxyFactory = 0; executed (the execution status of this line is deduced): d->proxyFactory = 0; | - |
482 | } executed: } Execution Count:1290 | 1290 |
483 | | - |
484 | /*! | - |
485 | \fn QNetworkProxyFactory *QNetworkAccessManager::proxyFactory() const | - |
486 | \since 4.5 | - |
487 | | - |
488 | Returns the proxy factory that this QNetworkAccessManager object | - |
489 | is using to determine the proxies to be used for requests. | - |
490 | | - |
491 | Note that the pointer returned by this function is managed by | - |
492 | QNetworkAccessManager and could be deleted at any time. | - |
493 | | - |
494 | \sa setProxyFactory(), proxy() | - |
495 | */ | - |
496 | QNetworkProxyFactory *QNetworkAccessManager::proxyFactory() const | - |
497 | { | - |
498 | return d_func()->proxyFactory; never executed: return d_func()->proxyFactory; | 0 |
499 | } | - |
500 | | - |
501 | /*! | - |
502 | \since 4.5 | - |
503 | | - |
504 | Sets the proxy factory for this class to be \a factory. A proxy | - |
505 | factory is used to determine a more specific list of proxies to be | - |
506 | used for a given request, instead of trying to use the same proxy | - |
507 | value for all requests. | - |
508 | | - |
509 | All queries sent by QNetworkAccessManager will have type | - |
510 | QNetworkProxyQuery::UrlRequest. | - |
511 | | - |
512 | For example, a proxy factory could apply the following rules: | - |
513 | \list | - |
514 | \li if the target address is in the local network (for example, | - |
515 | if the hostname contains no dots or if it's an IP address in | - |
516 | the organization's range), return QNetworkProxy::NoProxy | - |
517 | \li if the request is FTP, return an FTP proxy | - |
518 | \li if the request is HTTP or HTTPS, then return an HTTP proxy | - |
519 | \li otherwise, return a SOCKSv5 proxy server | - |
520 | \endlist | - |
521 | | - |
522 | The lifetime of the object \a factory will be managed by | - |
523 | QNetworkAccessManager. It will delete the object when necessary. | - |
524 | | - |
525 | \note If a specific proxy is set with setProxy(), the factory will not | - |
526 | be used. | - |
527 | | - |
528 | \sa proxyFactory(), setProxy(), QNetworkProxyQuery | - |
529 | */ | - |
530 | void QNetworkAccessManager::setProxyFactory(QNetworkProxyFactory *factory) | - |
531 | { | - |
532 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
533 | delete d->proxyFactory; executed (the execution status of this line is deduced): delete d->proxyFactory; | - |
534 | d->proxyFactory = factory; executed (the execution status of this line is deduced): d->proxyFactory = factory; | - |
535 | d->proxy = QNetworkProxy(); executed (the execution status of this line is deduced): d->proxy = QNetworkProxy(); | - |
536 | } executed: } Execution Count:20 | 20 |
537 | #endif | - |
538 | | - |
539 | /*! | - |
540 | \since 4.5 | - |
541 | | - |
542 | Returns the cache that is used to store data obtained from the network. | - |
543 | | - |
544 | \sa setCache() | - |
545 | */ | - |
546 | QAbstractNetworkCache *QNetworkAccessManager::cache() const | - |
547 | { | - |
548 | Q_D(const QNetworkAccessManager); never executed (the execution status of this line is deduced): const QNetworkAccessManagerPrivate * const d = d_func(); | - |
549 | return d->networkCache; never executed: return d->networkCache; | 0 |
550 | } | - |
551 | | - |
552 | /*! | - |
553 | \since 4.5 | - |
554 | | - |
555 | Sets the manager's network cache to be the \a cache specified. The cache | - |
556 | is used for all requests dispatched by the manager. | - |
557 | | - |
558 | Use this function to set the network cache object to a class that implements | - |
559 | additional features, like saving the cookies to permanent storage. | - |
560 | | - |
561 | \note QNetworkAccessManager takes ownership of the \a cache object. | - |
562 | | - |
563 | QNetworkAccessManager by default does not have a set cache. | - |
564 | Qt provides a simple disk cache, QNetworkDiskCache, which can be used. | - |
565 | | - |
566 | \sa cache(), QNetworkRequest::CacheLoadControl | - |
567 | */ | - |
568 | void QNetworkAccessManager::setCache(QAbstractNetworkCache *cache) | - |
569 | { | - |
570 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
571 | if (d->networkCache != cache) { evaluated: d->networkCache != cache yes Evaluation Count:92 | yes Evaluation Count:1152 |
| 92-1152 |
572 | delete d->networkCache; executed (the execution status of this line is deduced): delete d->networkCache; | - |
573 | d->networkCache = cache; executed (the execution status of this line is deduced): d->networkCache = cache; | - |
574 | if (d->networkCache) evaluated: d->networkCache yes Evaluation Count:67 | yes Evaluation Count:25 |
| 25-67 |
575 | d->networkCache->setParent(this); executed: d->networkCache->setParent(this); Execution Count:67 | 67 |
576 | } executed: } Execution Count:92 | 92 |
577 | } executed: } Execution Count:1244 | 1244 |
578 | | - |
579 | /*! | - |
580 | Returns the QNetworkCookieJar that is used to store cookies | - |
581 | obtained from the network as well as cookies that are about to be | - |
582 | sent. | - |
583 | | - |
584 | \sa setCookieJar() | - |
585 | */ | - |
586 | QNetworkCookieJar *QNetworkAccessManager::cookieJar() const | - |
587 | { | - |
588 | Q_D(const QNetworkAccessManager); executed (the execution status of this line is deduced): const QNetworkAccessManagerPrivate * const d = d_func(); | - |
589 | if (!d->cookieJar) partially evaluated: !d->cookieJar no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
590 | d->createCookieJar(); never executed: d->createCookieJar(); | 0 |
591 | return d->cookieJar; executed: return d->cookieJar; Execution Count:12 | 12 |
592 | } | - |
593 | | - |
594 | /*! | - |
595 | Sets the manager's cookie jar to be the \a cookieJar specified. | - |
596 | The cookie jar is used by all requests dispatched by the manager. | - |
597 | | - |
598 | Use this function to set the cookie jar object to a class that | - |
599 | implements additional features, like saving the cookies to permanent | - |
600 | storage. | - |
601 | | - |
602 | \note QNetworkAccessManager takes ownership of the \a cookieJar object. | - |
603 | | - |
604 | If \a cookieJar is in the same thread as this QNetworkAccessManager, | - |
605 | it will set the parent of the \a cookieJar | - |
606 | so that the cookie jar is deleted when this | - |
607 | object is deleted as well. If you want to share cookie jars | - |
608 | between different QNetworkAccessManager objects, you may want to | - |
609 | set the cookie jar's parent to 0 after calling this function. | - |
610 | | - |
611 | QNetworkAccessManager by default does not implement any cookie | - |
612 | policy of its own: it accepts all cookies sent by the server, as | - |
613 | long as they are well formed and meet the minimum security | - |
614 | requirements (cookie domain matches the request's and cookie path | - |
615 | matches the request's). In order to implement your own security | - |
616 | policy, override the QNetworkCookieJar::cookiesForUrl() and | - |
617 | QNetworkCookieJar::setCookiesFromUrl() virtual functions. Those | - |
618 | functions are called by QNetworkAccessManager when it detects a | - |
619 | new cookie. | - |
620 | | - |
621 | \sa cookieJar(), QNetworkCookieJar::cookiesForUrl(), QNetworkCookieJar::setCookiesFromUrl() | - |
622 | */ | - |
623 | void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar) | - |
624 | { | - |
625 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
626 | d->cookieJarCreated = true; executed (the execution status of this line is deduced): d->cookieJarCreated = true; | - |
627 | if (d->cookieJar != cookieJar) { partially evaluated: d->cookieJar != cookieJar yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
628 | if (d->cookieJar && d->cookieJar->parent() == this) partially evaluated: d->cookieJar no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: d->cookieJar->parent() == this | 0-1 |
629 | delete d->cookieJar; never executed: delete d->cookieJar; | 0 |
630 | d->cookieJar = cookieJar; executed (the execution status of this line is deduced): d->cookieJar = cookieJar; | - |
631 | if (thread() == cookieJar->thread()) partially evaluated: thread() == cookieJar->thread() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
632 | d->cookieJar->setParent(this); executed: d->cookieJar->setParent(this); Execution Count:1 | 1 |
633 | } executed: } Execution Count:1 | 1 |
634 | } executed: } Execution Count:1 | 1 |
635 | | - |
636 | /*! | - |
637 | Posts a request to obtain the network headers for \a request | - |
638 | and returns a new QNetworkReply object which will contain such headers. | - |
639 | | - |
640 | The function is named after the HTTP request associated (HEAD). | - |
641 | */ | - |
642 | QNetworkReply *QNetworkAccessManager::head(const QNetworkRequest &request) | - |
643 | { | - |
644 | return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request)); Execution Count:27 | 27 |
645 | } | - |
646 | | - |
647 | /*! | - |
648 | Posts a request to obtain the contents of the target \a request | - |
649 | and returns a new QNetworkReply object opened for reading which emits the | - |
650 | \l{QIODevice::readyRead()}{readyRead()} signal whenever new data | - |
651 | arrives. | - |
652 | | - |
653 | The contents as well as associated headers will be downloaded. | - |
654 | | - |
655 | \sa post(), put(), deleteResource(), sendCustomRequest() | - |
656 | */ | - |
657 | QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request) | - |
658 | { | - |
659 | return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request)); Execution Count:607 | 607 |
660 | } | - |
661 | | - |
662 | /*! | - |
663 | Sends an HTTP POST request to the destination specified by \a request | - |
664 | and returns a new QNetworkReply object opened for reading that will | - |
665 | contain the reply sent by the server. The contents of the \a data | - |
666 | device will be uploaded to the server. | - |
667 | | - |
668 | \a data must be open for reading and must remain valid until the | - |
669 | finished() signal is emitted for this reply. | - |
670 | | - |
671 | \note Sending a POST request on protocols other than HTTP and | - |
672 | HTTPS is undefined and will probably fail. | - |
673 | | - |
674 | \sa get(), put(), deleteResource(), sendCustomRequest() | - |
675 | */ | - |
676 | QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QIODevice *data) | - |
677 | { | - |
678 | return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data)); Execution Count:142 | 142 |
679 | } | - |
680 | | - |
681 | /*! | - |
682 | \overload | - |
683 | | - |
684 | Sends the contents of the \a data byte array to the destination | - |
685 | specified by \a request. | - |
686 | */ | - |
687 | QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, const QByteArray &data) | - |
688 | { | - |
689 | QBuffer *buffer = new QBuffer; executed (the execution status of this line is deduced): QBuffer *buffer = new QBuffer; | - |
690 | buffer->setData(data); executed (the execution status of this line is deduced): buffer->setData(data); | - |
691 | buffer->open(QIODevice::ReadOnly); executed (the execution status of this line is deduced): buffer->open(QIODevice::ReadOnly); | - |
692 | | - |
693 | QNetworkReply *reply = post(request, buffer); executed (the execution status of this line is deduced): QNetworkReply *reply = post(request, buffer); | - |
694 | buffer->setParent(reply); executed (the execution status of this line is deduced): buffer->setParent(reply); | - |
695 | return reply; executed: return reply; Execution Count:43 | 43 |
696 | } | - |
697 | | - |
698 | /*! | - |
699 | \since 4.8 | - |
700 | | - |
701 | \overload | - |
702 | | - |
703 | Sends the contents of the \a multiPart message to the destination | - |
704 | specified by \a request. | - |
705 | | - |
706 | This can be used for sending MIME multipart messages over HTTP. | - |
707 | | - |
708 | \sa QHttpMultiPart, QHttpPart, put() | - |
709 | */ | - |
710 | QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QHttpMultiPart *multiPart) | - |
711 | { | - |
712 | QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); executed (the execution status of this line is deduced): QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); | - |
713 | QIODevice *device = multiPart->d_func()->device; executed (the execution status of this line is deduced): QIODevice *device = multiPart->d_func()->device; | - |
714 | QNetworkReply *reply = post(newRequest, device); executed (the execution status of this line is deduced): QNetworkReply *reply = post(newRequest, device); | - |
715 | return reply; executed: return reply; Execution Count:22 | 22 |
716 | } | - |
717 | | - |
718 | /*! | - |
719 | \since 4.8 | - |
720 | | - |
721 | \overload | - |
722 | | - |
723 | Sends the contents of the \a multiPart message to the destination | - |
724 | specified by \a request. | - |
725 | | - |
726 | This can be used for sending MIME multipart messages over HTTP. | - |
727 | | - |
728 | \sa QHttpMultiPart, QHttpPart, post() | - |
729 | */ | - |
730 | QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QHttpMultiPart *multiPart) | - |
731 | { | - |
732 | QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); never executed (the execution status of this line is deduced): QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); | - |
733 | QIODevice *device = multiPart->d_func()->device; never executed (the execution status of this line is deduced): QIODevice *device = multiPart->d_func()->device; | - |
734 | QNetworkReply *reply = put(newRequest, device); never executed (the execution status of this line is deduced): QNetworkReply *reply = put(newRequest, device); | - |
735 | return reply; never executed: return reply; | 0 |
736 | } | - |
737 | | - |
738 | /*! | - |
739 | Uploads the contents of \a data to the destination \a request and | - |
740 | returnes a new QNetworkReply object that will be open for reply. | - |
741 | | - |
742 | \a data must be opened for reading when this function is called | - |
743 | and must remain valid until the finished() signal is emitted for | - |
744 | this reply. | - |
745 | | - |
746 | Whether anything will be available for reading from the returned | - |
747 | object is protocol dependent. For HTTP, the server may send a | - |
748 | small HTML page indicating the upload was successful (or not). | - |
749 | Other protocols will probably have content in their replies. | - |
750 | | - |
751 | \note For HTTP, this request will send a PUT request, which most servers | - |
752 | do not allow. Form upload mechanisms, including that of uploading | - |
753 | files through HTML forms, use the POST mechanism. | - |
754 | | - |
755 | \sa get(), post(), deleteResource(), sendCustomRequest() | - |
756 | */ | - |
757 | QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QIODevice *data) | - |
758 | { | - |
759 | return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data)); Execution Count:85 | 85 |
760 | } | - |
761 | | - |
762 | /*! | - |
763 | \overload | - |
764 | | - |
765 | Sends the contents of the \a data byte array to the destination | - |
766 | specified by \a request. | - |
767 | */ | - |
768 | QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, const QByteArray &data) | - |
769 | { | - |
770 | QBuffer *buffer = new QBuffer; executed (the execution status of this line is deduced): QBuffer *buffer = new QBuffer; | - |
771 | buffer->setData(data); executed (the execution status of this line is deduced): buffer->setData(data); | - |
772 | buffer->open(QIODevice::ReadOnly); executed (the execution status of this line is deduced): buffer->open(QIODevice::ReadOnly); | - |
773 | | - |
774 | QNetworkReply *reply = put(request, buffer); executed (the execution status of this line is deduced): QNetworkReply *reply = put(request, buffer); | - |
775 | buffer->setParent(reply); executed (the execution status of this line is deduced): buffer->setParent(reply); | - |
776 | return reply; executed: return reply; Execution Count:45 | 45 |
777 | } | - |
778 | | - |
779 | /*! | - |
780 | \since 4.6 | - |
781 | | - |
782 | Sends a request to delete the resource identified by the URL of \a request. | - |
783 | | - |
784 | \note This feature is currently available for HTTP only, performing an | - |
785 | HTTP DELETE request. | - |
786 | | - |
787 | \sa get(), post(), put(), sendCustomRequest() | - |
788 | */ | - |
789 | QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &request) | - |
790 | { | - |
791 | return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request)); Execution Count:7 | 7 |
792 | } | - |
793 | | - |
794 | #ifndef QT_NO_BEARERMANAGEMENT | - |
795 | | - |
796 | /*! | - |
797 | \since 4.7 | - |
798 | | - |
799 | Sets the network configuration that will be used when creating the | - |
800 | \l {QNetworkSession}{network session} to \a config. | - |
801 | | - |
802 | The network configuration is used to create and open a network session before any request that | - |
803 | requires network access is process. If no network configuration is explicitly set via this | - |
804 | function the network configuration returned by | - |
805 | QNetworkConfigurationManager::defaultConfiguration() will be used. | - |
806 | | - |
807 | To restore the default network configuration set the network configuration to the value | - |
808 | returned from QNetworkConfigurationManager::defaultConfiguration(). | - |
809 | | - |
810 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 2 | - |
811 | | - |
812 | If an invalid network configuration is set, a network session will not be created. In this | - |
813 | case network requests will be processed regardless, but may fail. For example: | - |
814 | | - |
815 | \snippet code/src_network_access_qnetworkaccessmanager.cpp 3 | - |
816 | | - |
817 | \sa configuration(), QNetworkSession | - |
818 | */ | - |
819 | void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config) | - |
820 | { | - |
821 | d_func()->createSession(config); executed (the execution status of this line is deduced): d_func()->createSession(config); | - |
822 | } executed: } Execution Count:5 | 5 |
823 | | - |
824 | /*! | - |
825 | \since 4.7 | - |
826 | | - |
827 | Returns the network configuration that will be used to create the | - |
828 | \l {QNetworkSession}{network session} which will be used when processing network requests. | - |
829 | | - |
830 | \sa setConfiguration(), activeConfiguration() | - |
831 | */ | - |
832 | QNetworkConfiguration QNetworkAccessManager::configuration() const | - |
833 | { | - |
834 | Q_D(const QNetworkAccessManager); never executed (the execution status of this line is deduced): const QNetworkAccessManagerPrivate * const d = d_func(); | - |
835 | | - |
836 | QSharedPointer<QNetworkSession> session(d->getNetworkSession()); never executed (the execution status of this line is deduced): QSharedPointer<QNetworkSession> session(d->getNetworkSession()); | - |
837 | if (session) | 0 |
838 | return session->configuration(); never executed: return session->configuration(); | 0 |
839 | else | - |
840 | return QNetworkConfiguration(); never executed: return QNetworkConfiguration(); | 0 |
841 | } | - |
842 | | - |
843 | /*! | - |
844 | \since 4.7 | - |
845 | | - |
846 | Returns the current active network configuration. | - |
847 | | - |
848 | If the network configuration returned by configuration() is of type | - |
849 | QNetworkConfiguration::ServiceNetwork this function will return the current active child | - |
850 | network configuration of that configuration. Otherwise returns the same network configuration | - |
851 | as configuration(). | - |
852 | | - |
853 | Use this function to return the actual network configuration currently in use by the network | - |
854 | session. | - |
855 | | - |
856 | \sa configuration() | - |
857 | */ | - |
858 | QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const | - |
859 | { | - |
860 | Q_D(const QNetworkAccessManager); never executed (the execution status of this line is deduced): const QNetworkAccessManagerPrivate * const d = d_func(); | - |
861 | | - |
862 | QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); never executed (the execution status of this line is deduced): QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); | - |
863 | if (networkSession) { never evaluated: networkSession | 0 |
864 | QNetworkConfigurationManager manager; never executed (the execution status of this line is deduced): QNetworkConfigurationManager manager; | - |
865 | | - |
866 | return manager.configurationFromIdentifier( never executed: return manager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); | 0 |
867 | networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); never executed: return manager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); | 0 |
868 | } else { | - |
869 | return QNetworkConfiguration(); never executed: return QNetworkConfiguration(); | 0 |
870 | } | - |
871 | } | - |
872 | | - |
873 | /*! | - |
874 | \since 4.7 | - |
875 | | - |
876 | Overrides the reported network accessibility. If \a accessible is NotAccessible the reported | - |
877 | network accessiblity will always be NotAccessible. Otherwise the reported network | - |
878 | accessibility will reflect the actual device state. | - |
879 | */ | - |
880 | void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkAccessibility accessible) | - |
881 | { | - |
882 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
883 | | - |
884 | if (d->networkAccessible != accessible) { partially evaluated: d->networkAccessible != accessible yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
885 | NetworkAccessibility previous = networkAccessible(); executed (the execution status of this line is deduced): NetworkAccessibility previous = networkAccessible(); | - |
886 | d->networkAccessible = accessible; executed (the execution status of this line is deduced): d->networkAccessible = accessible; | - |
887 | NetworkAccessibility current = networkAccessible(); executed (the execution status of this line is deduced): NetworkAccessibility current = networkAccessible(); | - |
888 | if (previous != current) partially evaluated: previous != current yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
889 | emit networkAccessibleChanged(current); executed: networkAccessibleChanged(current); Execution Count:3 | 3 |
890 | } executed: } Execution Count:3 | 3 |
891 | } executed: } Execution Count:3 | 3 |
892 | | - |
893 | /*! | - |
894 | \since 4.7 | - |
895 | | - |
896 | Returns the current network accessibility. | - |
897 | */ | - |
898 | QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccessible() const | - |
899 | { | - |
900 | Q_D(const QNetworkAccessManager); executed (the execution status of this line is deduced): const QNetworkAccessManagerPrivate * const d = d_func(); | - |
901 | | - |
902 | QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); executed (the execution status of this line is deduced): QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); | - |
903 | if (networkSession) { evaluated: networkSession yes Evaluation Count:4 | yes Evaluation Count:7 |
| 4-7 |
904 | // d->online holds online/offline state of this network session. | - |
905 | if (d->online) partially evaluated: d->online yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
906 | return d->networkAccessible; executed: return d->networkAccessible; Execution Count:4 | 4 |
907 | else | - |
908 | return NotAccessible; never executed: return NotAccessible; | 0 |
909 | } else { | - |
910 | // Network accessibility is either disabled or unknown. | - |
911 | return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility; executed: return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility; Execution Count:7 | 7 |
912 | } | - |
913 | } | - |
914 | | - |
915 | /*! | - |
916 | \internal | - |
917 | | - |
918 | Returns the network session currently in use. | - |
919 | This can be changed at any time, ownership remains with the QNetworkAccessManager | - |
920 | */ | - |
921 | const QWeakPointer<const QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession(const QNetworkAccessManager *q) | - |
922 | { | - |
923 | return q->d_func()->networkSessionWeakRef; never executed: return q->d_func()->networkSessionWeakRef; | 0 |
924 | } | - |
925 | | - |
926 | QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const | - |
927 | { | - |
928 | if (networkSessionStrongRef) evaluated: networkSessionStrongRef yes Evaluation Count:29 | yes Evaluation Count:3108 |
| 29-3108 |
929 | return networkSessionStrongRef; executed: return networkSessionStrongRef; Execution Count:29 | 29 |
930 | return networkSessionWeakRef.toStrongRef(); executed: return networkSessionWeakRef.toStrongRef(); Execution Count:3108 | 3108 |
931 | } | - |
932 | | - |
933 | #endif // QT_NO_BEARERMANAGEMENT | - |
934 | | - |
935 | /*! | - |
936 | \since 4.7 | - |
937 | | - |
938 | Sends a custom request to the server identified by the URL of \a request. | - |
939 | | - |
940 | It is the user's responsibility to send a \a verb to the server that is valid | - |
941 | according to the HTTP specification. | - |
942 | | - |
943 | This method provides means to send verbs other than the common ones provided | - |
944 | via get() or post() etc., for instance sending an HTTP OPTIONS command. | - |
945 | | - |
946 | If \a data is not empty, the contents of the \a data | - |
947 | device will be uploaded to the server; in that case, data must be open for | - |
948 | reading and must remain valid until the finished() signal is emitted for this reply. | - |
949 | | - |
950 | \note This feature is currently available for HTTP(S) only. | - |
951 | | - |
952 | \sa get(), post(), put(), deleteResource() | - |
953 | */ | - |
954 | QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data) | - |
955 | { | - |
956 | QNetworkRequest newRequest(request); executed (the execution status of this line is deduced): QNetworkRequest newRequest(request); | - |
957 | newRequest.setAttribute(QNetworkRequest::CustomVerbAttribute, verb); executed (the execution status of this line is deduced): newRequest.setAttribute(QNetworkRequest::CustomVerbAttribute, verb); | - |
958 | return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data)); executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data)); Execution Count:6 | 6 |
959 | } | - |
960 | | - |
961 | /*! | - |
962 | Returns a new QNetworkReply object to handle the operation \a op | - |
963 | and request \a req. The device \a outgoingData is always 0 for Get and | - |
964 | Head requests, but is the value passed to post() and put() in | - |
965 | those operations (the QByteArray variants will pass a QBuffer | - |
966 | object). | - |
967 | | - |
968 | The default implementation calls QNetworkCookieJar::cookiesForUrl() | - |
969 | on the cookie jar set with setCookieJar() to obtain the cookies to | - |
970 | be sent to the remote server. | - |
971 | | - |
972 | The returned object must be in an open state. | - |
973 | */ | - |
974 | QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, | - |
975 | const QNetworkRequest &req, | - |
976 | QIODevice *outgoingData) | - |
977 | { | - |
978 | Q_D(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate * const d = d_func(); | - |
979 | | - |
980 | bool isLocalFile = req.url().isLocalFile(); executed (the execution status of this line is deduced): bool isLocalFile = req.url().isLocalFile(); | - |
981 | QString scheme = req.url().scheme().toLower(); executed (the execution status of this line is deduced): QString scheme = req.url().scheme().toLower(); | - |
982 | | - |
983 | // fast path for GET on file:// URLs | - |
984 | // The QNetworkAccessFileBackend will right now only be used for PUT | - |
985 | if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) evaluated: op == QNetworkAccessManager::GetOperation yes Evaluation Count:607 | yes Evaluation Count:267 |
evaluated: op == QNetworkAccessManager::HeadOperation yes Evaluation Count:27 | yes Evaluation Count:240 |
| 27-607 |
986 | && (isLocalFile || scheme == QLatin1String("qrc"))) { evaluated: isLocalFile yes Evaluation Count:27 | yes Evaluation Count:607 |
evaluated: scheme == QLatin1String("qrc") yes Evaluation Count:2 | yes Evaluation Count:605 |
| 2-607 |
987 | return new QNetworkReplyFileImpl(this, req, op); executed: return new QNetworkReplyFileImpl(this, req, op); Execution Count:29 | 29 |
988 | } | - |
989 | | - |
990 | if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) evaluated: op == QNetworkAccessManager::GetOperation yes Evaluation Count:579 | yes Evaluation Count:266 |
evaluated: op == QNetworkAccessManager::HeadOperation yes Evaluation Count:26 | yes Evaluation Count:240 |
| 26-579 |
991 | && scheme == QLatin1String("data")) { evaluated: scheme == QLatin1String("data") yes Evaluation Count:30 | yes Evaluation Count:575 |
| 30-575 |
992 | return new QNetworkReplyDataImpl(this, req, op); executed: return new QNetworkReplyDataImpl(this, req, op); Execution Count:30 | 30 |
993 | } | - |
994 | | - |
995 | // A request with QNetworkRequest::AlwaysCache does not need any bearer management | - |
996 | QNetworkRequest::CacheLoadControl mode = executed (the execution status of this line is deduced): QNetworkRequest::CacheLoadControl mode = | - |
997 | static_cast<QNetworkRequest::CacheLoadControl>( executed (the execution status of this line is deduced): static_cast<QNetworkRequest::CacheLoadControl>( | - |
998 | req.attribute(QNetworkRequest::CacheLoadControlAttribute, executed (the execution status of this line is deduced): req.attribute(QNetworkRequest::CacheLoadControlAttribute, | - |
999 | QNetworkRequest::PreferNetwork).toInt()); executed (the execution status of this line is deduced): QNetworkRequest::PreferNetwork).toInt()); | - |
1000 | if (mode == QNetworkRequest::AlwaysCache evaluated: mode == QNetworkRequest::AlwaysCache yes Evaluation Count:13 | yes Evaluation Count:802 |
| 13-802 |
1001 | && (op == QNetworkAccessManager::GetOperation partially evaluated: op == QNetworkAccessManager::GetOperation yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
1002 | || op == QNetworkAccessManager::HeadOperation)) { never evaluated: op == QNetworkAccessManager::HeadOperation | 0 |
1003 | // FIXME Implement a QNetworkReplyCacheImpl instead, see QTBUG-15106 | - |
1004 | QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); executed (the execution status of this line is deduced): QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); | - |
1005 | QNetworkReplyImplPrivate *priv = reply->d_func(); executed (the execution status of this line is deduced): QNetworkReplyImplPrivate *priv = reply->d_func(); | - |
1006 | priv->manager = this; executed (the execution status of this line is deduced): priv->manager = this; | - |
1007 | priv->backend = new QNetworkAccessCacheBackend(); executed (the execution status of this line is deduced): priv->backend = new QNetworkAccessCacheBackend(); | - |
1008 | priv->backend->manager = this->d_func(); executed (the execution status of this line is deduced): priv->backend->manager = this->d_func(); | - |
1009 | priv->backend->setParent(reply); executed (the execution status of this line is deduced): priv->backend->setParent(reply); | - |
1010 | priv->backend->reply = priv; executed (the execution status of this line is deduced): priv->backend->reply = priv; | - |
1011 | priv->setup(op, req, outgoingData); executed (the execution status of this line is deduced): priv->setup(op, req, outgoingData); | - |
1012 | return reply; executed: return reply; Execution Count:13 | 13 |
1013 | } | - |
1014 | | - |
1015 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1016 | // Return a disabled network reply if network access is disabled. | - |
1017 | // Except if the scheme is empty or file://. | - |
1018 | if (!d->networkAccessible && !isLocalFile) { partially evaluated: !d->networkAccessible no Evaluation Count:0 | yes Evaluation Count:802 |
never evaluated: !isLocalFile | 0-802 |
1019 | return new QDisabledNetworkReply(this, req, op); never executed: return new QDisabledNetworkReply(this, req, op); | 0 |
1020 | } | - |
1021 | | - |
1022 | if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.isEmpty())) { evaluated: !d->networkSessionStrongRef yes Evaluation Count:798 | yes Evaluation Count:4 |
evaluated: d->initializeSession yes Evaluation Count:79 | yes Evaluation Count:719 |
partially evaluated: !d->networkConfiguration.isEmpty() no Evaluation Count:0 | yes Evaluation Count:719 |
| 0-798 |
1023 | QNetworkConfigurationManager manager; executed (the execution status of this line is deduced): QNetworkConfigurationManager manager; | - |
1024 | if (!d->networkConfiguration.isEmpty()) { partially evaluated: !d->networkConfiguration.isEmpty() no Evaluation Count:0 | yes Evaluation Count:79 |
| 0-79 |
1025 | d->createSession(manager.configurationFromIdentifier(d->networkConfiguration)); never executed (the execution status of this line is deduced): d->createSession(manager.configurationFromIdentifier(d->networkConfiguration)); | - |
1026 | } else { | 0 |
1027 | if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) partially evaluated: manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired no Evaluation Count:0 | yes Evaluation Count:79 |
| 0-79 |
1028 | d->createSession(manager.defaultConfiguration()); never executed: d->createSession(manager.defaultConfiguration()); | 0 |
1029 | else | - |
1030 | d->initializeSession = false; executed: d->initializeSession = false; Execution Count:79 | 79 |
1031 | } | - |
1032 | } | - |
1033 | #endif | - |
1034 | | - |
1035 | QNetworkRequest request = req; executed (the execution status of this line is deduced): QNetworkRequest request = req; | - |
1036 | if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() && evaluated: !request.header(QNetworkRequest::ContentLengthHeader).isValid() yes Evaluation Count:799 | yes Evaluation Count:3 |
| 3-799 |
1037 | outgoingData && !outgoingData->isSequential()) { evaluated: outgoingData yes Evaluation Count:226 | yes Evaluation Count:573 |
evaluated: !outgoingData->isSequential() yes Evaluation Count:131 | yes Evaluation Count:95 |
| 95-573 |
1038 | // request has no Content-Length | - |
1039 | // but the data that is outgoing is random-access | - |
1040 | request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size()); executed (the execution status of this line is deduced): request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size()); | - |
1041 | } executed: } Execution Count:131 | 131 |
1042 | | - |
1043 | if (static_cast<QNetworkRequest::LoadControl> partially evaluated: static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic yes Evaluation Count:802 | no Evaluation Count:0 |
| 0-802 |
1044 | (request.attribute(QNetworkRequest::CookieLoadControlAttribute, partially evaluated: static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic yes Evaluation Count:802 | no Evaluation Count:0 |
| 0-802 |
1045 | QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) { partially evaluated: static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic yes Evaluation Count:802 | no Evaluation Count:0 |
| 0-802 |
1046 | if (d->cookieJar) { evaluated: d->cookieJar yes Evaluation Count:593 | yes Evaluation Count:209 |
| 209-593 |
1047 | QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url()); executed (the execution status of this line is deduced): QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url()); | - |
1048 | if (!cookies.isEmpty()) evaluated: !cookies.isEmpty() yes Evaluation Count:8 | yes Evaluation Count:585 |
| 8-585 |
1049 | request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies)); executed: request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies)); Execution Count:8 | 8 |
1050 | } executed: } Execution Count:593 | 593 |
1051 | } executed: } Execution Count:802 | 802 |
1052 | | - |
1053 | #ifndef QT_NO_HTTP | - |
1054 | // Since Qt 5 we use the new QNetworkReplyHttpImpl | - |
1055 | if (scheme == QLatin1String("http") evaluated: scheme == QLatin1String("http") yes Evaluation Count:624 | yes Evaluation Count:178 |
| 178-624 |
1056 | #ifndef QT_NO_SSL executed (the execution status of this line is deduced):
| - |
1057 | || scheme == QLatin1String("https") evaluated: scheme == QLatin1String("https") yes Evaluation Count:89 | yes Evaluation Count:89 |
| 89 |
1058 | #endif | - |
1059 | ) { | - |
1060 | QNetworkReplyHttpImpl *reply = new QNetworkReplyHttpImpl(this, request, op, outgoingData); executed (the execution status of this line is deduced): QNetworkReplyHttpImpl *reply = new QNetworkReplyHttpImpl(this, request, op, outgoingData); | - |
1061 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1062 | connect(this, SIGNAL(networkSessionConnected()), executed (the execution status of this line is deduced): connect(this, "2""networkSessionConnected()", | - |
1063 | reply, SLOT(_q_networkSessionConnected())); executed (the execution status of this line is deduced): reply, "1""_q_networkSessionConnected()"); | - |
1064 | #endif | - |
1065 | return reply; executed: return reply; Execution Count:713 | 713 |
1066 | } | - |
1067 | #endif // QT_NO_HTTP | - |
1068 | | - |
1069 | // first step: create the reply | - |
1070 | QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); executed (the execution status of this line is deduced): QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); | - |
1071 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1072 | if (!isLocalFile) { evaluated: !isLocalFile yes Evaluation Count:50 | yes Evaluation Count:39 |
| 39-50 |
1073 | connect(this, SIGNAL(networkSessionConnected()), executed (the execution status of this line is deduced): connect(this, "2""networkSessionConnected()", | - |
1074 | reply, SLOT(_q_networkSessionConnected())); executed (the execution status of this line is deduced): reply, "1""_q_networkSessionConnected()"); | - |
1075 | } executed: } Execution Count:50 | 50 |
1076 | #endif | - |
1077 | QNetworkReplyImplPrivate *priv = reply->d_func(); executed (the execution status of this line is deduced): QNetworkReplyImplPrivate *priv = reply->d_func(); | - |
1078 | priv->manager = this; executed (the execution status of this line is deduced): priv->manager = this; | - |
1079 | | - |
1080 | // second step: fetch cached credentials | - |
1081 | // This is not done for the time being, we should use signal emissions to request | - |
1082 | // the credentials from cache. | - |
1083 | | - |
1084 | // third step: find a backend | - |
1085 | priv->backend = d->findBackend(op, request); executed (the execution status of this line is deduced): priv->backend = d->findBackend(op, request); | - |
1086 | | - |
1087 | if (priv->backend) { evaluated: priv->backend yes Evaluation Count:85 | yes Evaluation Count:4 |
| 4-85 |
1088 | priv->backend->setParent(reply); executed (the execution status of this line is deduced): priv->backend->setParent(reply); | - |
1089 | priv->backend->reply = priv; executed (the execution status of this line is deduced): priv->backend->reply = priv; | - |
1090 | } executed: } Execution Count:85 | 85 |
1091 | | - |
1092 | #ifndef QT_NO_SSL | - |
1093 | reply->setSslConfiguration(request.sslConfiguration()); executed (the execution status of this line is deduced): reply->setSslConfiguration(request.sslConfiguration()); | - |
1094 | #endif | - |
1095 | | - |
1096 | // fourth step: setup the reply | - |
1097 | priv->setup(op, request, outgoingData); executed (the execution status of this line is deduced): priv->setup(op, request, outgoingData); | - |
1098 | | - |
1099 | return reply; executed: return reply; Execution Count:89 | 89 |
1100 | } | - |
1101 | | - |
1102 | | - |
1103 | /*! | - |
1104 | \since 5.0 | - |
1105 | | - |
1106 | Flushes the internal cache of authentication data and network connections. | - |
1107 | | - |
1108 | This function is useful for doing auto tests. | - |
1109 | | - |
1110 | */ | - |
1111 | void QNetworkAccessManager::clearAccessCache() | - |
1112 | { | - |
1113 | QNetworkAccessManagerPrivate::clearCache(this); executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate::clearCache(this); | - |
1114 | } executed: } Execution Count:1176 | 1176 |
1115 | | - |
1116 | void QNetworkAccessManagerPrivate::_q_replyFinished() | - |
1117 | { | - |
1118 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1119 | | - |
1120 | QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); executed (the execution status of this line is deduced): QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); | - |
1121 | if (reply) partially evaluated: reply yes Evaluation Count:744 | no Evaluation Count:0 |
| 0-744 |
1122 | emit q->finished(reply); executed: q->finished(reply); Execution Count:744 | 744 |
1123 | | - |
1124 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1125 | // If there are no active requests, release our reference to the network session. | - |
1126 | // It will not be destroyed immediately, but rather when the connection cache is flushed | - |
1127 | // after 2 minutes. | - |
1128 | activeReplyCount--; executed (the execution status of this line is deduced): activeReplyCount--; | - |
1129 | if (networkSessionStrongRef && activeReplyCount == 0) evaluated: networkSessionStrongRef yes Evaluation Count:4 | yes Evaluation Count:740 |
partially evaluated: activeReplyCount == 0 yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-740 |
1130 | networkSessionStrongRef.clear(); executed: networkSessionStrongRef.clear(); Execution Count:4 | 4 |
1131 | #endif | - |
1132 | } executed: } Execution Count:744 | 744 |
1133 | | - |
1134 | void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &errors) | - |
1135 | { | - |
1136 | #ifndef QT_NO_SSL | - |
1137 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1138 | QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); executed (the execution status of this line is deduced): QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); | - |
1139 | if (reply) partially evaluated: reply yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-33 |
1140 | emit q->sslErrors(reply, errors); executed: q->sslErrors(reply, errors); Execution Count:33 | 33 |
1141 | #else | - |
1142 | Q_UNUSED(errors); | - |
1143 | #endif | - |
1144 | } executed: } Execution Count:33 | 33 |
1145 | | - |
1146 | QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply) | - |
1147 | { | - |
1148 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1149 | QNetworkReplyPrivate::setManager(reply, q); executed (the execution status of this line is deduced): QNetworkReplyPrivate::setManager(reply, q); | - |
1150 | q->connect(reply, SIGNAL(finished()), SLOT(_q_replyFinished())); executed (the execution status of this line is deduced): q->connect(reply, "2""finished()", "1""_q_replyFinished()"); | - |
1151 | #ifndef QT_NO_SSL | - |
1152 | /* In case we're compiled without SSL support, we don't have this signal and we need to | - |
1153 | * avoid getting a connection error. */ | - |
1154 | q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>))); executed (the execution status of this line is deduced): q->connect(reply, "2""sslErrors(QList<QSslError>)", "1""_q_replySslErrors(QList<QSslError>)"); | - |
1155 | #endif | - |
1156 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1157 | activeReplyCount++; executed (the execution status of this line is deduced): activeReplyCount++; | - |
1158 | #endif | - |
1159 | | - |
1160 | return reply; executed: return reply; Execution Count:874 | 874 |
1161 | } | - |
1162 | | - |
1163 | void QNetworkAccessManagerPrivate::createCookieJar() const | - |
1164 | { | - |
1165 | if (!cookieJarCreated) { never evaluated: !cookieJarCreated | 0 |
1166 | // keep the ugly hack in here | - |
1167 | QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this); never executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this); | - |
1168 | that->cookieJar = new QNetworkCookieJar(that->q_func()); never executed (the execution status of this line is deduced): that->cookieJar = new QNetworkCookieJar(that->q_func()); | - |
1169 | that->cookieJarCreated = true; never executed (the execution status of this line is deduced): that->cookieJarCreated = true; | - |
1170 | } | 0 |
1171 | } | 0 |
1172 | | - |
1173 | void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authenticator, | - |
1174 | QNetworkReply *reply, | - |
1175 | bool synchronous, | - |
1176 | QUrl &url, | - |
1177 | QUrl *urlForLastAuthentication, | - |
1178 | bool allowAuthenticationReuse) | - |
1179 | { | - |
1180 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1181 | | - |
1182 | // don't try the cache for the same URL twice in a row | - |
1183 | // being called twice for the same URL means the authentication failed | - |
1184 | // also called when last URL is empty, e.g. on first call | - |
1185 | if (allowAuthenticationReuse && (urlForLastAuthentication->isEmpty() evaluated: allowAuthenticationReuse yes Evaluation Count:113 | yes Evaluation Count:1 |
evaluated: urlForLastAuthentication->isEmpty() yes Evaluation Count:81 | yes Evaluation Count:32 |
| 1-113 |
1186 | || url != *urlForLastAuthentication)) { partially evaluated: url != *urlForLastAuthentication no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
1187 | // if credentials are included in the url, then use them | - |
1188 | if (!url.userName().isEmpty() evaluated: !url.userName().isEmpty() yes Evaluation Count:12 | yes Evaluation Count:69 |
| 12-69 |
1189 | && !url.password().isEmpty()) { partially evaluated: !url.password().isEmpty() yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
1190 | authenticator->setUser(url.userName()); executed (the execution status of this line is deduced): authenticator->setUser(url.userName()); | - |
1191 | authenticator->setPassword(url.password()); executed (the execution status of this line is deduced): authenticator->setPassword(url.password()); | - |
1192 | *urlForLastAuthentication = url; executed (the execution status of this line is deduced): *urlForLastAuthentication = url; | - |
1193 | authenticationManager->cacheCredentials(url, authenticator); executed (the execution status of this line is deduced): authenticationManager->cacheCredentials(url, authenticator); | - |
1194 | return; executed: return; Execution Count:12 | 12 |
1195 | } | - |
1196 | | - |
1197 | QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator); executed (the execution status of this line is deduced): QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator); | - |
1198 | if (!cred.isNull()) { evaluated: !cred.isNull() yes Evaluation Count:16 | yes Evaluation Count:53 |
| 16-53 |
1199 | authenticator->setUser(cred.user); executed (the execution status of this line is deduced): authenticator->setUser(cred.user); | - |
1200 | authenticator->setPassword(cred.password); executed (the execution status of this line is deduced): authenticator->setPassword(cred.password); | - |
1201 | *urlForLastAuthentication = url; executed (the execution status of this line is deduced): *urlForLastAuthentication = url; | - |
1202 | return; executed: return; Execution Count:16 | 16 |
1203 | } | - |
1204 | } executed: } Execution Count:53 | 53 |
1205 | | - |
1206 | #ifndef QT_NO_NETWORKPROXY | - |
1207 | #if defined(Q_OS_MAC) && !defined(Q_OS_IOS) | - |
1208 | //now we try to get the username and password from keychain | - |
1209 | //if not successful signal will be emitted | - |
1210 | QString username; | - |
1211 | QString password; | - |
1212 | if (getProxyAuth(proxy.hostName(),reply->request().url().scheme(),username,password)) { | - |
1213 | authenticator->setUser(username); | - |
1214 | authenticator->setPassword(password); | - |
1215 | authenticationManager->cacheProxyCredentials(proxy, authenticator); | - |
1216 | return; | - |
1217 | } | - |
1218 | #endif | - |
1219 | #endif //QT_NO_NETWORKPROXY | - |
1220 | | - |
1221 | // if we emit a signal here in synchronous mode, the user might spin | - |
1222 | // an event loop, which might recurse and lead to problems | - |
1223 | if (synchronous) partially evaluated: synchronous no Evaluation Count:0 | yes Evaluation Count:86 |
| 0-86 |
1224 | return; | 0 |
1225 | | - |
1226 | *urlForLastAuthentication = url; executed (the execution status of this line is deduced): *urlForLastAuthentication = url; | - |
1227 | emit q->authenticationRequired(reply, authenticator); executed (the execution status of this line is deduced): q->authenticationRequired(reply, authenticator); | - |
1228 | if (allowAuthenticationReuse) evaluated: allowAuthenticationReuse yes Evaluation Count:85 | yes Evaluation Count:1 |
| 1-85 |
1229 | authenticationManager->cacheCredentials(url, authenticator); executed: authenticationManager->cacheCredentials(url, authenticator); Execution Count:85 | 85 |
1230 | } executed: } Execution Count:86 | 86 |
1231 | | - |
1232 | #ifndef QT_NO_NETWORKPROXY | - |
1233 | void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(const QNetworkProxy &proxy, | - |
1234 | bool synchronous, | - |
1235 | QAuthenticator *authenticator, | - |
1236 | QNetworkProxy *lastProxyAuthentication) | - |
1237 | { | - |
1238 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1239 | QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator); executed (the execution status of this line is deduced): QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator); | - |
1240 | if (proxy != *lastProxyAuthentication && (!priv || !priv->hasFailed)) { evaluated: proxy != *lastProxyAuthentication yes Evaluation Count:59 | yes Evaluation Count:2 |
evaluated: !priv yes Evaluation Count:23 | yes Evaluation Count:36 |
evaluated: !priv->hasFailed yes Evaluation Count:34 | yes Evaluation Count:2 |
| 2-59 |
1241 | QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy); executed (the execution status of this line is deduced): QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy); | - |
1242 | if (!cred.isNull()) { evaluated: !cred.isNull() yes Evaluation Count:4 | yes Evaluation Count:53 |
| 4-53 |
1243 | authenticator->setUser(cred.user); executed (the execution status of this line is deduced): authenticator->setUser(cred.user); | - |
1244 | authenticator->setPassword(cred.password); executed (the execution status of this line is deduced): authenticator->setPassword(cred.password); | - |
1245 | return; executed: return; Execution Count:4 | 4 |
1246 | } | - |
1247 | } executed: } Execution Count:53 | 53 |
1248 | | - |
1249 | // if we emit a signal here in synchronous mode, the user might spin | - |
1250 | // an event loop, which might recurse and lead to problems | - |
1251 | if (synchronous) partially evaluated: synchronous no Evaluation Count:0 | yes Evaluation Count:57 |
| 0-57 |
1252 | return; | 0 |
1253 | | - |
1254 | *lastProxyAuthentication = proxy; executed (the execution status of this line is deduced): *lastProxyAuthentication = proxy; | - |
1255 | emit q->proxyAuthenticationRequired(proxy, authenticator); executed (the execution status of this line is deduced): q->proxyAuthenticationRequired(proxy, authenticator); | - |
1256 | authenticationManager->cacheProxyCredentials(proxy, authenticator); executed (the execution status of this line is deduced): authenticationManager->cacheProxyCredentials(proxy, authenticator); | - |
1257 | } executed: } Execution Count:57 | 57 |
1258 | | - |
1259 | QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProxyQuery &query) | - |
1260 | { | - |
1261 | QList<QNetworkProxy> proxies; executed (the execution status of this line is deduced): QList<QNetworkProxy> proxies; | - |
1262 | if (proxyFactory) { evaluated: proxyFactory yes Evaluation Count:20 | yes Evaluation Count:790 |
| 20-790 |
1263 | proxies = proxyFactory->queryProxy(query); executed (the execution status of this line is deduced): proxies = proxyFactory->queryProxy(query); | - |
1264 | if (proxies.isEmpty()) { partially evaluated: proxies.isEmpty() no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
1265 | qWarning("QNetworkAccessManager: factory %p has returned an empty result set", never executed (the execution status of this line is deduced): QMessageLogger("access/qnetworkaccessmanager.cpp", 1265, __PRETTY_FUNCTION__).warning("QNetworkAccessManager: factory %p has returned an empty result set", | - |
1266 | proxyFactory); never executed (the execution status of this line is deduced): proxyFactory); | - |
1267 | proxies << QNetworkProxy::NoProxy; never executed (the execution status of this line is deduced): proxies << QNetworkProxy::NoProxy; | - |
1268 | } | 0 |
1269 | } else if (proxy.type() == QNetworkProxy::DefaultProxy) { executed: } Execution Count:20 evaluated: proxy.type() == QNetworkProxy::DefaultProxy yes Evaluation Count:653 | yes Evaluation Count:137 |
| 20-653 |
1270 | // no proxy set, query the application | - |
1271 | return QNetworkProxyFactory::proxyForQuery(query); executed: return QNetworkProxyFactory::proxyForQuery(query); Execution Count:653 | 653 |
1272 | } else { | - |
1273 | proxies << proxy; executed (the execution status of this line is deduced): proxies << proxy; | - |
1274 | } executed: } Execution Count:137 | 137 |
1275 | | - |
1276 | return proxies; executed: return proxies; Execution Count:157 | 157 |
1277 | } | - |
1278 | #endif | - |
1279 | | - |
1280 | void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager) | - |
1281 | { | - |
1282 | manager->d_func()->objectCache.clear(); executed (the execution status of this line is deduced): manager->d_func()->objectCache.clear(); | - |
1283 | manager->d_func()->authenticationManager->clearCache(); executed (the execution status of this line is deduced): manager->d_func()->authenticationManager->clearCache(); | - |
1284 | | - |
1285 | if (manager->d_func()->httpThread) { evaluated: manager->d_func()->httpThread yes Evaluation Count:366 | yes Evaluation Count:810 |
| 366-810 |
1286 | manager->d_func()->httpThread->quit(); executed (the execution status of this line is deduced): manager->d_func()->httpThread->quit(); | - |
1287 | manager->d_func()->httpThread->wait(5000); executed (the execution status of this line is deduced): manager->d_func()->httpThread->wait(5000); | - |
1288 | if (manager->d_func()->httpThread->isFinished()) partially evaluated: manager->d_func()->httpThread->isFinished() yes Evaluation Count:366 | no Evaluation Count:0 |
| 0-366 |
1289 | delete manager->d_func()->httpThread; executed: delete manager->d_func()->httpThread; Execution Count:366 | 366 |
1290 | else | - |
1291 | QObject::connect(manager->d_func()->httpThread, SIGNAL(finished()), manager->d_func()->httpThread, SLOT(deleteLater())); never executed: QObject::connect(manager->d_func()->httpThread, "2""finished()", manager->d_func()->httpThread, "1""deleteLater()"); | 0 |
1292 | manager->d_func()->httpThread = 0; executed (the execution status of this line is deduced): manager->d_func()->httpThread = 0; | - |
1293 | } executed: } Execution Count:366 | 366 |
1294 | } executed: } Execution Count:1176 | 1176 |
1295 | | - |
1296 | QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() | - |
1297 | { | - |
1298 | if (httpThread) { evaluated: httpThread yes Evaluation Count:70 | yes Evaluation Count:15 |
| 15-70 |
1299 | httpThread->quit(); executed (the execution status of this line is deduced): httpThread->quit(); | - |
1300 | httpThread->wait(5000); executed (the execution status of this line is deduced): httpThread->wait(5000); | - |
1301 | if (httpThread->isFinished()) partially evaluated: httpThread->isFinished() yes Evaluation Count:70 | no Evaluation Count:0 |
| 0-70 |
1302 | delete httpThread; executed: delete httpThread; Execution Count:70 | 70 |
1303 | else | - |
1304 | QObject::connect(httpThread, SIGNAL(finished()), httpThread, SLOT(deleteLater())); never executed: QObject::connect(httpThread, "2""finished()", httpThread, "1""deleteLater()"); | 0 |
1305 | httpThread = 0; executed (the execution status of this line is deduced): httpThread = 0; | - |
1306 | } executed: } Execution Count:70 | 70 |
1307 | } executed: } Execution Count:85 | 85 |
1308 | | - |
1309 | #ifndef QT_NO_BEARERMANAGEMENT | - |
1310 | void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &config) | - |
1311 | { | - |
1312 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1313 | | - |
1314 | initializeSession = false; executed (the execution status of this line is deduced): initializeSession = false; | - |
1315 | | - |
1316 | //resurrect weak ref if possible | - |
1317 | networkSessionStrongRef = networkSessionWeakRef.toStrongRef(); executed (the execution status of this line is deduced): networkSessionStrongRef = networkSessionWeakRef.toStrongRef(); | - |
1318 | | - |
1319 | QSharedPointer<QNetworkSession> newSession; executed (the execution status of this line is deduced): QSharedPointer<QNetworkSession> newSession; | - |
1320 | if (config.isValid()) partially evaluated: config.isValid() yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
1321 | newSession = QSharedNetworkSessionManager::getSession(config); executed: newSession = QSharedNetworkSessionManager::getSession(config); Execution Count:5 | 5 |
1322 | | - |
1323 | if (networkSessionStrongRef) { partially evaluated: networkSessionStrongRef no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1324 | //do nothing if new and old session are the same | - |
1325 | if (networkSessionStrongRef == newSession) never evaluated: networkSessionStrongRef == newSession | 0 |
1326 | return; | 0 |
1327 | //disconnect from old session | - |
1328 | QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected())); never executed (the execution status of this line is deduced): QObject::disconnect(networkSessionStrongRef.data(), "2""opened()", q, "2""networkSessionConnected()"); | - |
1329 | QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed())); never executed (the execution status of this line is deduced): QObject::disconnect(networkSessionStrongRef.data(), "2""closed()", q, "1""_q_networkSessionClosed()"); | - |
1330 | QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)), never executed (the execution status of this line is deduced): QObject::disconnect(networkSessionStrongRef.data(), "2""stateChanged(QNetworkSession::State)", | - |
1331 | q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State))); never executed (the execution status of this line is deduced): q, "1""_q_networkSessionStateChanged(QNetworkSession::State)"); | - |
1332 | } | 0 |
1333 | | - |
1334 | //switch to new session (null if config was invalid) | - |
1335 | networkSessionStrongRef = newSession; executed (the execution status of this line is deduced): networkSessionStrongRef = newSession; | - |
1336 | networkSessionWeakRef = networkSessionStrongRef.toWeakRef(); executed (the execution status of this line is deduced): networkSessionWeakRef = networkSessionStrongRef.toWeakRef(); | - |
1337 | | - |
1338 | if (!networkSessionStrongRef) { partially evaluated: !networkSessionStrongRef no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1339 | online = false; never executed (the execution status of this line is deduced): online = false; | - |
1340 | | - |
1341 | if (networkAccessible == QNetworkAccessManager::NotAccessible) never evaluated: networkAccessible == QNetworkAccessManager::NotAccessible | 0 |
1342 | emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); never executed: q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); | 0 |
1343 | else | - |
1344 | emit q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility); never executed: q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility); | 0 |
1345 | | - |
1346 | return; | 0 |
1347 | } | - |
1348 | | - |
1349 | //connect to new session | - |
1350 | QObject::connect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()), Qt::QueuedConnection); executed (the execution status of this line is deduced): QObject::connect(networkSessionStrongRef.data(), "2""opened()", q, "2""networkSessionConnected()", Qt::QueuedConnection); | - |
1351 | //QueuedConnection is used to avoid deleting the networkSession inside its closed signal | - |
1352 | QObject::connect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection); executed (the execution status of this line is deduced): QObject::connect(networkSessionStrongRef.data(), "2""closed()", q, "1""_q_networkSessionClosed()", Qt::QueuedConnection); | - |
1353 | QObject::connect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)), executed (the execution status of this line is deduced): QObject::connect(networkSessionStrongRef.data(), "2""stateChanged(QNetworkSession::State)", | - |
1354 | q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection); executed (the execution status of this line is deduced): q, "1""_q_networkSessionStateChanged(QNetworkSession::State)", Qt::QueuedConnection); | - |
1355 | | - |
1356 | _q_networkSessionStateChanged(networkSessionStrongRef->state()); executed (the execution status of this line is deduced): _q_networkSessionStateChanged(networkSessionStrongRef->state()); | - |
1357 | } executed: } Execution Count:5 | 5 |
1358 | | - |
1359 | void QNetworkAccessManagerPrivate::_q_networkSessionClosed() | - |
1360 | { | - |
1361 | Q_Q(QNetworkAccessManager); never executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1362 | QSharedPointer<QNetworkSession> networkSession(getNetworkSession()); never executed (the execution status of this line is deduced): QSharedPointer<QNetworkSession> networkSession(getNetworkSession()); | - |
1363 | if (networkSession) { never evaluated: networkSession | 0 |
1364 | networkConfiguration = networkSession->configuration().identifier(); never executed (the execution status of this line is deduced): networkConfiguration = networkSession->configuration().identifier(); | - |
1365 | | - |
1366 | //disconnect from old session | - |
1367 | QObject::disconnect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected())); never executed (the execution status of this line is deduced): QObject::disconnect(networkSession.data(), "2""opened()", q, "2""networkSessionConnected()"); | - |
1368 | QObject::disconnect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed())); never executed (the execution status of this line is deduced): QObject::disconnect(networkSession.data(), "2""closed()", q, "1""_q_networkSessionClosed()"); | - |
1369 | QObject::disconnect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)), never executed (the execution status of this line is deduced): QObject::disconnect(networkSession.data(), "2""stateChanged(QNetworkSession::State)", | - |
1370 | q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State))); never executed (the execution status of this line is deduced): q, "1""_q_networkSessionStateChanged(QNetworkSession::State)"); | - |
1371 | networkSessionStrongRef.clear(); never executed (the execution status of this line is deduced): networkSessionStrongRef.clear(); | - |
1372 | networkSessionWeakRef.clear(); never executed (the execution status of this line is deduced): networkSessionWeakRef.clear(); | - |
1373 | } | 0 |
1374 | } | 0 |
1375 | | - |
1376 | void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state) | - |
1377 | { | - |
1378 | Q_Q(QNetworkAccessManager); executed (the execution status of this line is deduced): QNetworkAccessManager * const q = q_func(); | - |
1379 | | - |
1380 | //Do not emit the networkSessionConnected signal here, except for roaming -> connected | - |
1381 | //transition, otherwise it is emitted twice in a row when opening a connection. | - |
1382 | if (state == QNetworkSession::Connected && lastSessionState == QNetworkSession::Roaming) evaluated: state == QNetworkSession::Connected yes Evaluation Count:4 | yes Evaluation Count:2 |
partially evaluated: lastSessionState == QNetworkSession::Roaming no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1383 | emit q->networkSessionConnected(); never executed: q->networkSessionConnected(); | 0 |
1384 | lastSessionState = state; executed (the execution status of this line is deduced): lastSessionState = state; | - |
1385 | | - |
1386 | if (online) { partially evaluated: online no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1387 | if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) { never evaluated: state != QNetworkSession::Connected never evaluated: state != QNetworkSession::Roaming | 0 |
1388 | online = false; never executed (the execution status of this line is deduced): online = false; | - |
1389 | emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); never executed (the execution status of this line is deduced): q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); | - |
1390 | } | 0 |
1391 | } else { | 0 |
1392 | if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) { evaluated: state == QNetworkSession::Connected yes Evaluation Count:4 | yes Evaluation Count:2 |
partially evaluated: state == QNetworkSession::Roaming no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-4 |
1393 | online = true; executed (the execution status of this line is deduced): online = true; | - |
1394 | emit q->networkAccessibleChanged(networkAccessible); executed (the execution status of this line is deduced): q->networkAccessibleChanged(networkAccessible); | - |
1395 | } executed: } Execution Count:4 | 4 |
1396 | } executed: } Execution Count:6 | 6 |
1397 | } | - |
1398 | #endif // QT_NO_BEARERMANAGEMENT | - |
1399 | | - |
1400 | QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart) | - |
1401 | { | - |
1402 | // copy the request, we probably need to add some headers | - |
1403 | QNetworkRequest newRequest(request); executed (the execution status of this line is deduced): QNetworkRequest newRequest(request); | - |
1404 | | - |
1405 | // add Content-Type header if not there already | - |
1406 | if (!request.header(QNetworkRequest::ContentTypeHeader).isValid()) { evaluated: !request.header(QNetworkRequest::ContentTypeHeader).isValid() yes Evaluation Count:20 | yes Evaluation Count:2 |
| 2-20 |
1407 | QByteArray contentType; executed (the execution status of this line is deduced): QByteArray contentType; | - |
1408 | contentType.reserve(34 + multiPart->d_func()->boundary.count()); executed (the execution status of this line is deduced): contentType.reserve(34 + multiPart->d_func()->boundary.count()); | - |
1409 | contentType += "multipart/"; executed (the execution status of this line is deduced): contentType += "multipart/"; | - |
1410 | switch (multiPart->d_func()->contentType) { | - |
1411 | case QHttpMultiPart::RelatedType: | - |
1412 | contentType += "related"; executed (the execution status of this line is deduced): contentType += "related"; | - |
1413 | break; executed: break; Execution Count:2 | 2 |
1414 | case QHttpMultiPart::FormDataType: | - |
1415 | contentType += "form-data"; executed (the execution status of this line is deduced): contentType += "form-data"; | - |
1416 | break; executed: break; Execution Count:12 | 12 |
1417 | case QHttpMultiPart::AlternativeType: | - |
1418 | contentType += "alternative"; executed (the execution status of this line is deduced): contentType += "alternative"; | - |
1419 | break; executed: break; Execution Count:4 | 4 |
1420 | default: | - |
1421 | contentType += "mixed"; executed (the execution status of this line is deduced): contentType += "mixed"; | - |
1422 | break; executed: break; Execution Count:2 | 2 |
1423 | } | - |
1424 | // putting the boundary into quotes, recommended in RFC 2046 section 5.1.1 | - |
1425 | contentType += "; boundary=\"" + multiPart->d_func()->boundary + "\""; executed (the execution status of this line is deduced): contentType += "; boundary=\"" + multiPart->d_func()->boundary + "\""; | - |
1426 | newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(contentType)); executed (the execution status of this line is deduced): newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(contentType)); | - |
1427 | } executed: } Execution Count:20 | 20 |
1428 | | - |
1429 | // add MIME-Version header if not there already (we must include the header | - |
1430 | // if the message conforms to RFC 2045, see section 4 of that RFC) | - |
1431 | QByteArray mimeHeader("MIME-Version"); executed (the execution status of this line is deduced): QByteArray mimeHeader("MIME-Version"); | - |
1432 | if (!request.hasRawHeader(mimeHeader)) partially evaluated: !request.hasRawHeader(mimeHeader) yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1433 | newRequest.setRawHeader(mimeHeader, QByteArray("1.0")); executed: newRequest.setRawHeader(mimeHeader, QByteArray("1.0")); Execution Count:22 | 22 |
1434 | | - |
1435 | QIODevice *device = multiPart->d_func()->device; executed (the execution status of this line is deduced): QIODevice *device = multiPart->d_func()->device; | - |
1436 | if (!device->isReadable()) { partially evaluated: !device->isReadable() yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1437 | if (!device->isOpen()) { partially evaluated: !device->isOpen() yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
1438 | if (!device->open(QIODevice::ReadOnly)) partially evaluated: !device->open(QIODevice::ReadOnly) no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
1439 | qWarning("could not open device for reading"); never executed: QMessageLogger("access/qnetworkaccessmanager.cpp", 1439, __PRETTY_FUNCTION__).warning("could not open device for reading"); | 0 |
1440 | } else { executed: } Execution Count:22 | 22 |
1441 | qWarning("device is not readable"); never executed (the execution status of this line is deduced): QMessageLogger("access/qnetworkaccessmanager.cpp", 1441, __PRETTY_FUNCTION__).warning("device is not readable"); | - |
1442 | } | 0 |
1443 | } | - |
1444 | | - |
1445 | return newRequest; executed: return newRequest; Execution Count:22 | 22 |
1446 | } | - |
1447 | | - |
1448 | QT_END_NAMESPACE | - |
1449 | | - |
1450 | #include "moc_qnetworkaccessmanager.cpp" | - |
1451 | | - |
| | |