access/qnetworkaccessmanager.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12static QNetworkAccessFileBackendFactory *fileBackend() { static QGlobalStatic<QNetworkAccessFileBackendFactory > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QNetworkAccessFileBackendFactory *x = new QNetworkAccessFileBackendFactory; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QNetworkAccessFileBackendFactory > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:85
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:77
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-85
13 -
14static QNetworkAccessFtpBackendFactory *ftpBackend() { static QGlobalStatic<QNetworkAccessFtpBackendFactory > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QNetworkAccessFtpBackendFactory *x = new QNetworkAccessFtpBackendFactory; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QNetworkAccessFtpBackendFactory > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:77
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:85
0-85
15static void ensureInitialized() -
16{ -
17 -
18 (void) ftpBackend(); -
19 -
20 -
21 -
22 -
23 -
24 -
25 -
26 (void) fileBackend(); -
27}
executed: }
Execution Count:85
85
28QNetworkAccessManager::QNetworkAccessManager(QObject *parent) -
29 : QObject(*new QNetworkAccessManagerPrivate, parent) -
30{ -
31 ensureInitialized(); -
32 -
33 qRegisterMetaType<QNetworkReply::NetworkError>(); -
34 -
35 qRegisterMetaType<QNetworkProxy>(); -
36 -
37 -
38 qRegisterMetaType<QList<QSslError> >(); -
39 qRegisterMetaType<QSslConfiguration>(); -
40 -
41 qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >(); -
42 -
43 qRegisterMetaType<QHttpNetworkRequest>(); -
44 -
45 qRegisterMetaType<QNetworkReply::NetworkError>(); -
46 qRegisterMetaType<QSharedPointer<char> >(); -
47}
executed: }
Execution Count:85
85
48QNetworkAccessManager::~QNetworkAccessManager() -
49{ -
50 -
51 delete d_func()->proxyFactory; -
52 -
53 -
54 -
55 -
56 -
57 -
58 qDeleteAll(findChildren<QNetworkReply *>()); -
59 -
60 -
61 -
62}
executed: }
Execution Count:85
85
63QNetworkProxy QNetworkAccessManager::proxy() const -
64{ -
65 return d_func()->proxy;
never executed: return d_func()->proxy;
0
66} -
67void QNetworkAccessManager::setProxy(const QNetworkProxy &proxy) -
68{ -
69 QNetworkAccessManagerPrivate * const d = d_func(); -
70 delete d->proxyFactory; -
71 d->proxy = proxy; -
72 d->proxyFactory = 0; -
73}
executed: }
Execution Count:1290
1290
74QNetworkProxyFactory *QNetworkAccessManager::proxyFactory() const -
75{ -
76 return d_func()->proxyFactory;
never executed: return d_func()->proxyFactory;
0
77} -
78void QNetworkAccessManager::setProxyFactory(QNetworkProxyFactory *factory) -
79{ -
80 QNetworkAccessManagerPrivate * const d = d_func(); -
81 delete d->proxyFactory; -
82 d->proxyFactory = factory; -
83 d->proxy = QNetworkProxy(); -
84}
executed: }
Execution Count:20
20
85QAbstractNetworkCache *QNetworkAccessManager::cache() const -
86{ -
87 const QNetworkAccessManagerPrivate * const d = d_func(); -
88 return d->networkCache;
never executed: return d->networkCache;
0
89} -
90void QNetworkAccessManager::setCache(QAbstractNetworkCache *cache) -
91{ -
92 QNetworkAccessManagerPrivate * const d = d_func(); -
93 if (d->networkCache != cache) {
evaluated: d->networkCache != cache
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:1152
92-1152
94 delete d->networkCache; -
95 d->networkCache = cache; -
96 if (d->networkCache)
evaluated: d->networkCache
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:25
25-67
97 d->networkCache->setParent(this);
executed: d->networkCache->setParent(this);
Execution Count:67
67
98 }
executed: }
Execution Count:92
92
99}
executed: }
Execution Count:1244
1244
100QNetworkCookieJar *QNetworkAccessManager::cookieJar() const -
101{ -
102 const QNetworkAccessManagerPrivate * const d = d_func(); -
103 if (!d->cookieJar)
partially evaluated: !d->cookieJar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
104 d->createCookieJar();
never executed: d->createCookieJar();
0
105 return d->cookieJar;
executed: return d->cookieJar;
Execution Count:12
12
106} -
107void QNetworkAccessManager::setCookieJar(QNetworkCookieJar *cookieJar) -
108{ -
109 QNetworkAccessManagerPrivate * const d = d_func(); -
110 d->cookieJarCreated = true; -
111 if (d->cookieJar != cookieJar) {
partially evaluated: d->cookieJar != cookieJar
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
112 if (d->cookieJar && d->cookieJar->parent() == this)
partially evaluated: d->cookieJar
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: d->cookieJar->parent() == this
0-1
113 delete d->cookieJar;
never executed: delete d->cookieJar;
0
114 d->cookieJar = cookieJar; -
115 if (thread() == cookieJar->thread())
partially evaluated: thread() == cookieJar->thread()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
116 d->cookieJar->setParent(this);
executed: d->cookieJar->setParent(this);
Execution Count:1
1
117 }
executed: }
Execution Count:1
1
118}
executed: }
Execution Count:1
1
119 -
120 -
121 -
122 -
123 -
124 -
125 -
126QNetworkReply *QNetworkAccessManager::head(const QNetworkRequest &request) -
127{ -
128 return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::HeadOperation, request));
Execution Count:27
27
129} -
130QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request) -
131{ -
132 return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request));
Execution Count:607
607
133} -
134QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QIODevice *data) -
135{ -
136 return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::PostOperation, request, data));
Execution Count:142
142
137} -
138 -
139 -
140 -
141 -
142 -
143 -
144 -
145QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, const QByteArray &data) -
146{ -
147 QBuffer *buffer = new QBuffer; -
148 buffer->setData(data); -
149 buffer->open(QIODevice::ReadOnly); -
150 -
151 QNetworkReply *reply = post(request, buffer); -
152 buffer->setParent(reply); -
153 return reply;
executed: return reply;
Execution Count:43
43
154} -
155QNetworkReply *QNetworkAccessManager::post(const QNetworkRequest &request, QHttpMultiPart *multiPart) -
156{ -
157 QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); -
158 QIODevice *device = multiPart->d_func()->device; -
159 QNetworkReply *reply = post(newRequest, device); -
160 return reply;
executed: return reply;
Execution Count:22
22
161} -
162QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QHttpMultiPart *multiPart) -
163{ -
164 QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart); -
165 QIODevice *device = multiPart->d_func()->device; -
166 QNetworkReply *reply = put(newRequest, device); -
167 return reply;
never executed: return reply;
0
168} -
169QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, QIODevice *data) -
170{ -
171 return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::PutOperation, request, data));
Execution Count:85
85
172} -
173 -
174 -
175 -
176 -
177 -
178 -
179 -
180QNetworkReply *QNetworkAccessManager::put(const QNetworkRequest &request, const QByteArray &data) -
181{ -
182 QBuffer *buffer = new QBuffer; -
183 buffer->setData(data); -
184 buffer->open(QIODevice::ReadOnly); -
185 -
186 QNetworkReply *reply = put(request, buffer); -
187 buffer->setParent(reply); -
188 return reply;
executed: return reply;
Execution Count:45
45
189} -
190QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &request) -
191{ -
192 return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request));
Execution Count:7
7
193} -
194void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config) -
195{ -
196 d_func()->createSession(config); -
197}
executed: }
Execution Count:5
5
198QNetworkConfiguration QNetworkAccessManager::configuration() const -
199{ -
200 const QNetworkAccessManagerPrivate * const d = d_func(); -
201 -
202 QSharedPointer<QNetworkSession> session(d->getNetworkSession()); -
203 if (session)
never evaluated: session
0
204 return session->configuration();
never executed: return session->configuration();
0
205 else -
206 return QNetworkConfiguration();
never executed: return QNetworkConfiguration();
0
207} -
208QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const -
209{ -
210 const QNetworkAccessManagerPrivate * const d = d_func(); -
211 -
212 QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); -
213 if (networkSession) {
never evaluated: networkSession
0
214 QNetworkConfigurationManager manager; -
215 -
216 return manager.configurationFromIdentifier( 0
217 networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
never executed: return manager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
0
218 } else { -
219 return QNetworkConfiguration();
never executed: return QNetworkConfiguration();
0
220 } -
221} -
222void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkAccessibility accessible) -
223{ -
224 QNetworkAccessManagerPrivate * const d = d_func(); -
225 -
226 if (d->networkAccessible != accessible) {
partially evaluated: d->networkAccessible != accessible
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
227 NetworkAccessibility previous = networkAccessible(); -
228 d->networkAccessible = accessible; -
229 NetworkAccessibility current = networkAccessible(); -
230 if (previous != current)
partially evaluated: previous != current
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
231 networkAccessibleChanged(current);
executed: networkAccessibleChanged(current);
Execution Count:3
3
232 }
executed: }
Execution Count:3
3
233}
executed: }
Execution Count:3
3
234 -
235 -
236 -
237 -
238 -
239 -
240QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccessible() const -
241{ -
242 const QNetworkAccessManagerPrivate * const d = d_func(); -
243 -
244 QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); -
245 if (networkSession) {
evaluated: networkSession
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7
4-7
246 -
247 if (d->online)
partially evaluated: d->online
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
248 return d->networkAccessible;
executed: return d->networkAccessible;
Execution Count:4
4
249 else -
250 return NotAccessible;
never executed: return NotAccessible;
0
251 } else { -
252 -
253 return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility;
executed: return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility;
Execution Count:7
7
254 } -
255} -
256 -
257 -
258 -
259 -
260 -
261 -
262 -
263const QWeakPointer<const QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession(const QNetworkAccessManager *q) -
264{ -
265 return q->d_func()->networkSessionWeakRef;
never executed: return q->d_func()->networkSessionWeakRef;
0
266} -
267 -
268QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const -
269{ -
270 if (networkSessionStrongRef)
evaluated: networkSessionStrongRef
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:3108
29-3108
271 return networkSessionStrongRef;
executed: return networkSessionStrongRef;
Execution Count:29
29
272 return networkSessionWeakRef.toStrongRef();
executed: return networkSessionWeakRef.toStrongRef();
Execution Count:3108
3108
273} -
274QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data) -
275{ -
276 QNetworkRequest newRequest(request); -
277 newRequest.setAttribute(QNetworkRequest::CustomVerbAttribute, verb); -
278 return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data));
executed: return d_func()->postProcess(createRequest(QNetworkAccessManager::CustomOperation, newRequest, data));
Execution Count:6
6
279} -
280QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, -
281 const QNetworkRequest &req, -
282 QIODevice *outgoingData) -
283{ -
284 QNetworkAccessManagerPrivate * const d = d_func(); -
285 -
286 bool isLocalFile = req.url().isLocalFile(); -
287 QString scheme = req.url().scheme().toLower(); -
288 -
289 -
290 -
291 if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation)
evaluated: op == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:607
yes
Evaluation Count:267
evaluated: op == QNetworkAccessManager::HeadOperation
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:240
27-607
292 && (isLocalFile || scheme == QLatin1String("qrc"))) {
evaluated: isLocalFile
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:607
evaluated: scheme == QLatin1String("qrc")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:605
2-607
293 return new QNetworkReplyFileImpl(this, req, op);
executed: return new QNetworkReplyFileImpl(this, req, op);
Execution Count:29
29
294 } -
295 -
296 if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation)
evaluated: op == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:579
yes
Evaluation Count:266
evaluated: op == QNetworkAccessManager::HeadOperation
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:240
26-579
297 && scheme == QLatin1String("data")) {
evaluated: scheme == QLatin1String("data")
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:575
30-575
298 return new QNetworkReplyDataImpl(this, req, op);
executed: return new QNetworkReplyDataImpl(this, req, op);
Execution Count:30
30
299 } -
300 -
301 -
302 QNetworkRequest::CacheLoadControl mode = -
303 static_cast<QNetworkRequest::CacheLoadControl>( -
304 req.attribute(QNetworkRequest::CacheLoadControlAttribute, -
305 QNetworkRequest::PreferNetwork).toInt()); -
306 if (mode == QNetworkRequest::AlwaysCache
evaluated: mode == QNetworkRequest::AlwaysCache
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:802
13-802
307 && (op == QNetworkAccessManager::GetOperation
partially evaluated: op == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
308 || op == QNetworkAccessManager::HeadOperation)) {
never evaluated: op == QNetworkAccessManager::HeadOperation
0
309 -
310 QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); -
311 QNetworkReplyImplPrivate *priv = reply->d_func(); -
312 priv->manager = this; -
313 priv->backend = new QNetworkAccessCacheBackend(); -
314 priv->backend->manager = this->d_func(); -
315 priv->backend->setParent(reply); -
316 priv->backend->reply = priv; -
317 priv->setup(op, req, outgoingData); -
318 return reply;
executed: return reply;
Execution Count:13
13
319 } -
320 -
321 -
322 -
323 -
324 if (!d->networkAccessible && !isLocalFile) {
partially evaluated: !d->networkAccessible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:802
never evaluated: !isLocalFile
0-802
325 return new QDisabledNetworkReply(this, req, op);
never executed: return new QDisabledNetworkReply(this, req, op);
0
326 } -
327 -
328 if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.isEmpty())) {
evaluated: !d->networkSessionStrongRef
TRUEFALSE
yes
Evaluation Count:798
yes
Evaluation Count:4
evaluated: d->initializeSession
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:719
partially evaluated: !d->networkConfiguration.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:719
0-798
329 QNetworkConfigurationManager manager; -
330 if (!d->networkConfiguration.isEmpty()) {
partially evaluated: !d->networkConfiguration.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:79
0-79
331 d->createSession(manager.configurationFromIdentifier(d->networkConfiguration)); -
332 } else {
never executed: }
0
333 if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
partially evaluated: manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:79
0-79
334 d->createSession(manager.defaultConfiguration());
never executed: d->createSession(manager.defaultConfiguration());
0
335 else -
336 d->initializeSession = false;
executed: d->initializeSession = false;
Execution Count:79
79
337 } -
338 } -
339 -
340 -
341 QNetworkRequest request = req; -
342 if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
evaluated: !request.header(QNetworkRequest::ContentLengthHeader).isValid()
TRUEFALSE
yes
Evaluation Count:799
yes
Evaluation Count:3
3-799
343 outgoingData && !outgoingData->isSequential()) {
evaluated: outgoingData
TRUEFALSE
yes
Evaluation Count:226
yes
Evaluation Count:573
evaluated: !outgoingData->isSequential()
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:95
95-573
344 -
345 -
346 request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size()); -
347 }
executed: }
Execution Count:131
131
348 -
349 if (static_cast<QNetworkRequest::LoadControl> 0-802
350 (request.attribute(QNetworkRequest::CookieLoadControlAttribute, 0-802
351 QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) {
partially evaluated: static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic
TRUEFALSE
yes
Evaluation Count:802
no
Evaluation Count:0
0-802
352 if (d->cookieJar) {
evaluated: d->cookieJar
TRUEFALSE
yes
Evaluation Count:593
yes
Evaluation Count:209
209-593
353 QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url()); -
354 if (!cookies.isEmpty())
evaluated: !cookies.isEmpty()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:585
8-585
355 request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
executed: request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies));
Execution Count:8
8
356 }
executed: }
Execution Count:593
593
357 }
executed: }
Execution Count:802
802
358 -
359 -
360 -
361 if (scheme == QLatin1String("http")
evaluated: scheme == QLatin1String("http")
TRUEFALSE
yes
Evaluation Count:624
yes
Evaluation Count:178
178-624
362 -
363 || scheme == QLatin1String("https")
evaluated: scheme == QLatin1String("https")
TRUEFALSE
yes
Evaluation Count:89
yes
Evaluation Count:89
89
364 -
365 ) { -
366 QNetworkReplyHttpImpl *reply = new QNetworkReplyHttpImpl(this, request, op, outgoingData); -
367 -
368 connect(this, "2""networkSessionConnected()", -
369 reply, "1""_q_networkSessionConnected()"); -
370 -
371 return reply;
executed: return reply;
Execution Count:713
713
372 } -
373 -
374 -
375 -
376 QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); -
377 -
378 if (!isLocalFile) {
evaluated: !isLocalFile
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:39
39-50
379 connect(this, "2""networkSessionConnected()", -
380 reply, "1""_q_networkSessionConnected()"); -
381 }
executed: }
Execution Count:50
50
382 -
383 QNetworkReplyImplPrivate *priv = reply->d_func(); -
384 priv->manager = this; -
385 -
386 -
387 -
388 -
389 -
390 -
391 priv->backend = d->findBackend(op, request); -
392 -
393 if (priv->backend) {
evaluated: priv->backend
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:4
4-85
394 priv->backend->setParent(reply); -
395 priv->backend->reply = priv; -
396 }
executed: }
Execution Count:85
85
397 -
398 -
399 reply->setSslConfiguration(request.sslConfiguration()); -
400 -
401 -
402 -
403 priv->setup(op, request, outgoingData); -
404 -
405 return reply;
executed: return reply;
Execution Count:89
89
406} -
407void QNetworkAccessManager::clearAccessCache() -
408{ -
409 QNetworkAccessManagerPrivate::clearCache(this); -
410}
executed: }
Execution Count:1176
1176
411 -
412void QNetworkAccessManagerPrivate::_q_replyFinished() -
413{ -
414 QNetworkAccessManager * const q = q_func(); -
415 -
416 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); -
417 if (reply)
partially evaluated: reply
TRUEFALSE
yes
Evaluation Count:744
no
Evaluation Count:0
0-744
418 q->finished(reply);
executed: q->finished(reply);
Execution Count:744
744
419 -
420 -
421 -
422 -
423 -
424 activeReplyCount--; -
425 if (networkSessionStrongRef && activeReplyCount == 0)
evaluated: networkSessionStrongRef
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:740
partially evaluated: activeReplyCount == 0
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-740
426 networkSessionStrongRef.clear();
executed: networkSessionStrongRef.clear();
Execution Count:4
4
427 -
428}
executed: }
Execution Count:744
744
429 -
430void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &errors) -
431{ -
432 -
433 QNetworkAccessManager * const q = q_func(); -
434 QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); -
435 if (reply)
partially evaluated: reply
TRUEFALSE
yes
Evaluation Count:33
no
Evaluation Count:0
0-33
436 q->sslErrors(reply, errors);
executed: q->sslErrors(reply, errors);
Execution Count:33
33
437 -
438 -
439 -
440}
executed: }
Execution Count:33
33
441 -
442QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply) -
443{ -
444 QNetworkAccessManager * const q = q_func(); -
445 QNetworkReplyPrivate::setManager(reply, q); -
446 q->connect(reply, "2""finished()", "1""_q_replyFinished()"); -
447 -
448 -
449 -
450 q->connect(reply, "2""sslErrors(QList<QSslError>)", "1""_q_replySslErrors(QList<QSslError>)"); -
451 -
452 -
453 activeReplyCount++; -
454 -
455 -
456 return reply;
executed: return reply;
Execution Count:874
874
457} -
458 -
459void QNetworkAccessManagerPrivate::createCookieJar() const -
460{ -
461 if (!cookieJarCreated) {
never evaluated: !cookieJarCreated
0
462 -
463 QNetworkAccessManagerPrivate *that = const_cast<QNetworkAccessManagerPrivate *>(this); -
464 that->cookieJar = new QNetworkCookieJar(that->q_func()); -
465 that->cookieJarCreated = true; -
466 }
never executed: }
0
467}
never executed: }
0
468 -
469void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authenticator, -
470 QNetworkReply *reply, -
471 bool synchronous, -
472 QUrl &url, -
473 QUrl *urlForLastAuthentication, -
474 bool allowAuthenticationReuse) -
475{ -
476 QNetworkAccessManager * const q = q_func(); -
477 -
478 -
479 -
480 -
481 if (allowAuthenticationReuse && (urlForLastAuthentication->isEmpty()
evaluated: allowAuthenticationReuse
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:1
evaluated: urlForLastAuthentication->isEmpty()
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:32
1-113
482 || url != *urlForLastAuthentication)) {
partially evaluated: url != *urlForLastAuthentication
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:32
0-32
483 -
484 if (!url.userName().isEmpty()
evaluated: !url.userName().isEmpty()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:69
12-69
485 && !url.password().isEmpty()) {
partially evaluated: !url.password().isEmpty()
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
486 authenticator->setUser(url.userName()); -
487 authenticator->setPassword(url.password()); -
488 *urlForLastAuthentication = url; -
489 authenticationManager->cacheCredentials(url, authenticator); -
490 return;
executed: return;
Execution Count:12
12
491 } -
492 -
493 QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator); -
494 if (!cred.isNull()) {
evaluated: !cred.isNull()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:53
16-53
495 authenticator->setUser(cred.user); -
496 authenticator->setPassword(cred.password); -
497 *urlForLastAuthentication = url; -
498 return;
executed: return;
Execution Count:16
16
499 } -
500 }
executed: }
Execution Count:53
53
501 if (synchronous)
partially evaluated: synchronous
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:86
0-86
502 return;
never executed: return;
0
503 -
504 *urlForLastAuthentication = url; -
505 q->authenticationRequired(reply, authenticator); -
506 if (allowAuthenticationReuse)
evaluated: allowAuthenticationReuse
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:1
1-85
507 authenticationManager->cacheCredentials(url, authenticator);
executed: authenticationManager->cacheCredentials(url, authenticator);
Execution Count:85
85
508}
executed: }
Execution Count:86
86
509 -
510 -
511void QNetworkAccessManagerPrivate::proxyAuthenticationRequired(const QNetworkProxy &proxy, -
512 bool synchronous, -
513 QAuthenticator *authenticator, -
514 QNetworkProxy *lastProxyAuthentication) -
515{ -
516 QNetworkAccessManager * const q = q_func(); -
517 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*authenticator); -
518 if (proxy != *lastProxyAuthentication && (!priv || !priv->hasFailed)) {
evaluated: proxy != *lastProxyAuthentication
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:2
evaluated: !priv
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:36
evaluated: !priv->hasFailed
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:2
2-59
519 QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedProxyCredentials(proxy); -
520 if (!cred.isNull()) {
evaluated: !cred.isNull()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:53
4-53
521 authenticator->setUser(cred.user); -
522 authenticator->setPassword(cred.password); -
523 return;
executed: return;
Execution Count:4
4
524 } -
525 }
executed: }
Execution Count:53
53
526 -
527 -
528 -
529 if (synchronous)
partially evaluated: synchronous
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:57
0-57
530 return;
never executed: return;
0
531 -
532 *lastProxyAuthentication = proxy; -
533 q->proxyAuthenticationRequired(proxy, authenticator); -
534 authenticationManager->cacheProxyCredentials(proxy, authenticator); -
535}
executed: }
Execution Count:57
57
536 -
537QList<QNetworkProxy> QNetworkAccessManagerPrivate::queryProxy(const QNetworkProxyQuery &query) -
538{ -
539 QList<QNetworkProxy> proxies; -
540 if (proxyFactory) {
evaluated: proxyFactory
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:790
20-790
541 proxies = proxyFactory->queryProxy(query); -
542 if (proxies.isEmpty()) {
partially evaluated: proxies.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
543 QMessageLogger("access/qnetworkaccessmanager.cpp", 1265, __PRETTY_FUNCTION__).warning("QNetworkAccessManager: factory %p has returned an empty result set", -
544 proxyFactory); -
545 proxies << QNetworkProxy::NoProxy; -
546 }
never executed: }
0
547 } else if (proxy.type() == QNetworkProxy::DefaultProxy) {
evaluated: proxy.type() == QNetworkProxy::DefaultProxy
TRUEFALSE
yes
Evaluation Count:653
yes
Evaluation Count:137
executed: }
Execution Count:20
20-653
548 -
549 return QNetworkProxyFactory::proxyForQuery(query);
executed: return QNetworkProxyFactory::proxyForQuery(query);
Execution Count:653
653
550 } else { -
551 proxies << proxy; -
552 }
executed: }
Execution Count:137
137
553 -
554 return proxies;
executed: return proxies;
Execution Count:157
157
555} -
556 -
557 -
558void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager) -
559{ -
560 manager->d_func()->objectCache.clear(); -
561 manager->d_func()->authenticationManager->clearCache(); -
562 -
563 if (manager->d_func()->httpThread) {
evaluated: manager->d_func()->httpThread
TRUEFALSE
yes
Evaluation Count:366
yes
Evaluation Count:810
366-810
564 manager->d_func()->httpThread->quit(); -
565 manager->d_func()->httpThread->wait(5000); -
566 if (manager->d_func()->httpThread->isFinished())
partially evaluated: manager->d_func()->httpThread->isFinished()
TRUEFALSE
yes
Evaluation Count:366
no
Evaluation Count:0
0-366
567 delete manager->d_func()->httpThread;
executed: delete manager->d_func()->httpThread;
Execution Count:366
366
568 else -
569 QObject::connect(manager->d_func()->httpThread, "2""finished()", manager->d_func()->httpThread, "1""deleteLater()");
never executed: QObject::connect(manager->d_func()->httpThread, "2""finished()", manager->d_func()->httpThread, "1""deleteLater()");
0
570 manager->d_func()->httpThread = 0; -
571 }
executed: }
Execution Count:366
366
572}
executed: }
Execution Count:1176
1176
573 -
574QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() -
575{ -
576 if (httpThread) {
evaluated: httpThread
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:15
15-70
577 httpThread->quit(); -
578 httpThread->wait(5000); -
579 if (httpThread->isFinished())
partially evaluated: httpThread->isFinished()
TRUEFALSE
yes
Evaluation Count:70
no
Evaluation Count:0
0-70
580 delete httpThread;
executed: delete httpThread;
Execution Count:70
70
581 else -
582 QObject::connect(httpThread, "2""finished()", httpThread, "1""deleteLater()");
never executed: QObject::connect(httpThread, "2""finished()", httpThread, "1""deleteLater()");
0
583 httpThread = 0; -
584 }
executed: }
Execution Count:70
70
585}
executed: }
Execution Count:85
85
586 -
587 -
588void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &config) -
589{ -
590 QNetworkAccessManager * const q = q_func(); -
591 -
592 initializeSession = false; -
593 -
594 -
595 networkSessionStrongRef = networkSessionWeakRef.toStrongRef(); -
596 -
597 QSharedPointer<QNetworkSession> newSession; -
598 if (config.isValid())
partially evaluated: config.isValid()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
599 newSession = QSharedNetworkSessionManager::getSession(config);
executed: newSession = QSharedNetworkSessionManager::getSession(config);
Execution Count:5
5
600 -
601 if (networkSessionStrongRef) {
partially evaluated: networkSessionStrongRef
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
602 -
603 if (networkSessionStrongRef == newSession)
never evaluated: networkSessionStrongRef == newSession
0
604 return;
never executed: return;
0
605 -
606 QObject::disconnect(networkSessionStrongRef.data(), "2""opened()", q, "2""networkSessionConnected()"); -
607 QObject::disconnect(networkSessionStrongRef.data(), "2""closed()", q, "1""_q_networkSessionClosed()"); -
608 QObject::disconnect(networkSessionStrongRef.data(), "2""stateChanged(QNetworkSession::State)", -
609 q, "1""_q_networkSessionStateChanged(QNetworkSession::State)"); -
610 }
never executed: }
0
611 -
612 -
613 networkSessionStrongRef = newSession; -
614 networkSessionWeakRef = networkSessionStrongRef.toWeakRef(); -
615 -
616 if (!networkSessionStrongRef) {
partially evaluated: !networkSessionStrongRef
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
617 online = false; -
618 -
619 if (networkAccessible == QNetworkAccessManager::NotAccessible)
never evaluated: networkAccessible == QNetworkAccessManager::NotAccessible
0
620 q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
never executed: q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
0
621 else -
622 q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility);
never executed: q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility);
0
623 -
624 return;
never executed: return;
0
625 } -
626 -
627 -
628 QObject::connect(networkSessionStrongRef.data(), "2""opened()", q, "2""networkSessionConnected()", Qt::QueuedConnection); -
629 -
630 QObject::connect(networkSessionStrongRef.data(), "2""closed()", q, "1""_q_networkSessionClosed()", Qt::QueuedConnection); -
631 QObject::connect(networkSessionStrongRef.data(), "2""stateChanged(QNetworkSession::State)", -
632 q, "1""_q_networkSessionStateChanged(QNetworkSession::State)", Qt::QueuedConnection); -
633 -
634 _q_networkSessionStateChanged(networkSessionStrongRef->state()); -
635}
executed: }
Execution Count:5
5
636 -
637void QNetworkAccessManagerPrivate::_q_networkSessionClosed() -
638{ -
639 QNetworkAccessManager * const q = q_func(); -
640 QSharedPointer<QNetworkSession> networkSession(getNetworkSession()); -
641 if (networkSession) {
never evaluated: networkSession
0
642 networkConfiguration = networkSession->configuration().identifier(); -
643 -
644 -
645 QObject::disconnect(networkSession.data(), "2""opened()", q, "2""networkSessionConnected()"); -
646 QObject::disconnect(networkSession.data(), "2""closed()", q, "1""_q_networkSessionClosed()"); -
647 QObject::disconnect(networkSession.data(), "2""stateChanged(QNetworkSession::State)", -
648 q, "1""_q_networkSessionStateChanged(QNetworkSession::State)"); -
649 networkSessionStrongRef.clear(); -
650 networkSessionWeakRef.clear(); -
651 }
never executed: }
0
652}
never executed: }
0
653 -
654void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state) -
655{ -
656 QNetworkAccessManager * const q = q_func(); -
657 -
658 -
659 -
660 if (state == QNetworkSession::Connected && lastSessionState == QNetworkSession::Roaming)
evaluated: state == QNetworkSession::Connected
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
partially evaluated: lastSessionState == QNetworkSession::Roaming
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
661 q->networkSessionConnected();
never executed: q->networkSessionConnected();
0
662 lastSessionState = state; -
663 -
664 if (online) {
partially evaluated: online
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
665 if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) {
never evaluated: state != QNetworkSession::Connected
never evaluated: state != QNetworkSession::Roaming
0
666 online = false; -
667 q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); -
668 }
never executed: }
0
669 } else {
never executed: }
0
670 if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) {
evaluated: state == QNetworkSession::Connected
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
partially evaluated: state == QNetworkSession::Roaming
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-4
671 online = true; -
672 q->networkAccessibleChanged(networkAccessible); -
673 }
executed: }
Execution Count:4
4
674 }
executed: }
Execution Count:6
6
675} -
676 -
677 -
678QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart) -
679{ -
680 -
681 QNetworkRequest newRequest(request); -
682 -
683 -
684 if (!request.header(QNetworkRequest::ContentTypeHeader).isValid()) {
evaluated: !request.header(QNetworkRequest::ContentTypeHeader).isValid()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:2
2-20
685 QByteArray contentType; -
686 contentType.reserve(34 + multiPart->d_func()->boundary.count()); -
687 contentType += "multipart/"; -
688 switch (multiPart->d_func()->contentType) { -
689 case QHttpMultiPart::RelatedType: -
690 contentType += "related"; -
691 break;
executed: break;
Execution Count:2
2
692 case QHttpMultiPart::FormDataType: -
693 contentType += "form-data"; -
694 break;
executed: break;
Execution Count:12
12
695 case QHttpMultiPart::AlternativeType: -
696 contentType += "alternative"; -
697 break;
executed: break;
Execution Count:4
4
698 default: -
699 contentType += "mixed"; -
700 break;
executed: break;
Execution Count:2
2
701 } -
702 -
703 contentType += "; boundary=\"" + multiPart->d_func()->boundary + "\""; -
704 newRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(contentType)); -
705 }
executed: }
Execution Count:20
20
706 -
707 -
708 -
709 QByteArray mimeHeader("MIME-Version"); -
710 if (!request.hasRawHeader(mimeHeader))
partially evaluated: !request.hasRawHeader(mimeHeader)
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
711 newRequest.setRawHeader(mimeHeader, QByteArray("1.0"));
executed: newRequest.setRawHeader(mimeHeader, QByteArray("1.0"));
Execution Count:22
22
712 -
713 QIODevice *device = multiPart->d_func()->device; -
714 if (!device->isReadable()) {
partially evaluated: !device->isReadable()
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
715 if (!device->isOpen()) {
partially evaluated: !device->isOpen()
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
716 if (!device->open(QIODevice::ReadOnly))
partially evaluated: !device->open(QIODevice::ReadOnly)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
717 QMessageLogger("access/qnetworkaccessmanager.cpp", 1439, __PRETTY_FUNCTION__).warning("could not open device for reading");
never executed: QMessageLogger("access/qnetworkaccessmanager.cpp", 1439, __PRETTY_FUNCTION__).warning("could not open device for reading");
0
718 } else {
executed: }
Execution Count:22
22
719 QMessageLogger("access/qnetworkaccessmanager.cpp", 1441, __PRETTY_FUNCTION__).warning("device is not readable"); -
720 }
never executed: }
0
721 } -
722 -
723 return newRequest;
executed: return newRequest;
Execution Count:22
22
724} -
725 -
726 -
727 -
728 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial