access/qnetworkreplyhttpimpl.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11 -
12class QNetworkProxy; -
13 -
14static inline bool isSeparator(register char c) -
15{ -
16 static const char separators[] = "()<>@,;:\\\"/[]?={}"; -
17 return isLWS(c) || strchr(separators, c) != 0;
executed: return isLWS(c) || strchr(separators, c) != 0;
Execution Count:157
157
18} -
19 -
20 -
21static QHash<QByteArray, QByteArray> parseHttpOptionHeader(const QByteArray &header) -
22{ -
23 -
24 -
25 -
26 -
27 QHash<QByteArray, QByteArray> result; -
28 -
29 int pos = 0; -
30 while (true) {
partially evaluated: true
TRUEFALSE
yes
Evaluation Count:91
no
Evaluation Count:0
0-91
31 -
32 pos = nextNonWhitespace(header, pos); -
33 if (pos == header.length())
evaluated: pos == header.length()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:69
22-69
34 return result;
executed: return result;
Execution Count:22
22
35 -
36 -
37 int comma = header.indexOf(',', pos); -
38 int equal = header.indexOf('=', pos); -
39 if (comma == pos || equal == pos)
partially evaluated: comma == pos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
partially evaluated: equal == pos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:69
0-69
40 -
41 return result;
never executed: return result;
0
42 -
43 -
44 -
45 int end = comma; -
46 if (end == -1)
evaluated: end == -1
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:19
19-50
47 end = header.length();
executed: end = header.length();
Execution Count:50
50
48 if (equal != -1 && end > equal)
evaluated: equal != -1
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:22
evaluated: end > equal
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:4
4-47
49 end = equal;
executed: end = equal;
Execution Count:43
43
50 QByteArray key = QByteArray(header.constData() + pos, end - pos).trimmed().toLower(); -
51 pos = end + 1; -
52 -
53 if (uint(equal) < uint(comma)) {
evaluated: uint(equal) < uint(comma)
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:26
26-43
54 -
55 -
56 pos = nextNonWhitespace(header, pos); -
57 if (pos == header.length())
partially evaluated: pos == header.length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
58 -
59 return result;
never executed: return result;
0
60 -
61 QByteArray value; -
62 value.reserve(header.length() - pos); -
63 if (header.at(pos) == '"') {
partially evaluated: header.at(pos) == '"'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
64 -
65 -
66 -
67 -
68 ++pos; -
69 while (pos < header.length()) {
never evaluated: pos < header.length()
0
70 register char c = header.at(pos); -
71 if (c == '"') {
never evaluated: c == '"'
0
72 -
73 break;
never executed: break;
0
74 } else if (c == '\\') {
never evaluated: c == '\\'
0
75 ++pos; -
76 if (pos >= header.length())
never evaluated: pos >= header.length()
0
77 -
78 return result;
never executed: return result;
0
79 c = header.at(pos); -
80 }
never executed: }
0
81 -
82 value += c; -
83 ++pos; -
84 }
never executed: }
0
85 } else {
never executed: }
0
86 -
87 while (pos < header.length()) {
evaluated: pos < header.length()
TRUEFALSE
yes
Evaluation Count:157
yes
Evaluation Count:28
28-157
88 register char c = header.at(pos); -
89 if (isSeparator(c))
evaluated: isSeparator(c)
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:142
15-142
90 break;
executed: break;
Execution Count:15
15
91 value += c; -
92 ++pos; -
93 }
executed: }
Execution Count:142
142
94 }
executed: }
Execution Count:43
43
95 -
96 result.insert(key, value); -
97 -
98 -
99 comma = header.indexOf(',', pos); -
100 if (comma == -1)
evaluated: comma == -1
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:15
15-28
101 return result;
executed: return result;
Execution Count:28
28
102 pos = comma + 1; -
103 } else {
executed: }
Execution Count:15
15
104 -
105 -
106 result.insert(key, QByteArray()); -
107 }
executed: }
Execution Count:26
26
108 } -
109}
never executed: }
0
110 -
111QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manager, -
112 const QNetworkRequest& request, -
113 QNetworkAccessManager::Operation& operation, -
114 QIODevice* outgoingData) -
115 : QNetworkReply(*new QNetworkReplyHttpImplPrivate, manager) -
116{ -
117 QNetworkReplyHttpImplPrivate * const d = d_func(); -
118 d->manager = manager; -
119 d->managerPrivate = manager->d_func(); -
120 d->request = request; -
121 d->operation = operation; -
122 d->outgoingData = outgoingData; -
123 d->url = request.url(); -
124 -
125 d->sslConfiguration = request.sslConfiguration(); -
126 -
127 -
128 -
129 QIODevice::open(QIODevice::ReadOnly); -
130 -
131 -
132 -
133 -
134 QVariant synchronousHttpAttribute = request.attribute( -
135 static_cast<QNetworkRequest::Attribute>(QNetworkRequest::SynchronousRequestAttribute)); -
136 if (synchronousHttpAttribute.isValid()) {
evaluated: synchronousHttpAttribute.isValid()
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:637
76-637
137 d->synchronous = synchronousHttpAttribute.toBool(); -
138 if (d->synchronous && outgoingData) {
partially evaluated: d->synchronous
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
evaluated: outgoingData
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:35
0-76
139 -
140 -
141 d->outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer()); -
142 qint64 previousDataSize = 0; -
143 do { -
144 previousDataSize = d->outgoingDataBuffer->size(); -
145 d->outgoingDataBuffer->append(d->outgoingData->readAll()); -
146 } while (d->outgoingDataBuffer->size() != previousDataSize);
executed: }
Execution Count:77
evaluated: d->outgoingDataBuffer->size() != previousDataSize
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:41
36-77
147 d->_q_startOperation(); -
148 return;
executed: return;
Execution Count:41
41
149 } -
150 }
executed: }
Execution Count:35
35
151 -
152 -
153 if (outgoingData) {
evaluated: outgoingData
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:534
138-534
154 -
155 -
156 if (!d->outgoingData->isSequential()) {
evaluated: !d->outgoingData->isSequential()
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:61
61-77
157 -
158 -
159 QMetaObject::invokeMethod(this, "_q_startOperation", Qt::QueuedConnection); -
160 -
161 } else {
executed: }
Execution Count:77
77
162 bool bufferingDisallowed = -
163 request.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute, -
164 false).toBool(); -
165 -
166 if (bufferingDisallowed) {
evaluated: bufferingDisallowed
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
1-60
167 -
168 -
169 if (request.header(QNetworkRequest::ContentLengthHeader).isValid()) {
partially evaluated: request.header(QNetworkRequest::ContentLengthHeader).isValid()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
170 QMetaObject::invokeMethod(this, "_q_startOperation", Qt::QueuedConnection); -
171 -
172 } else {
executed: }
Execution Count:1
1
173 d->state = d->Buffering; -
174 QMetaObject::invokeMethod(this, "_q_bufferOutgoingData", Qt::QueuedConnection); -
175 }
never executed: }
0
176 } else { -
177 -
178 d->state = d->Buffering; -
179 QMetaObject::invokeMethod(this, "_q_bufferOutgoingData", Qt::QueuedConnection); -
180 }
executed: }
Execution Count:60
60
181 } -
182 } else { -
183 -
184 d->_q_startOperation(); -
185 }
executed: }
Execution Count:534
534
186} -
187 -
188QNetworkReplyHttpImpl::~QNetworkReplyHttpImpl() -
189{ -
190 -
191} -
192 -
193void QNetworkReplyHttpImpl::close() -
194{ -
195 QNetworkReplyHttpImplPrivate * const d = d_func(); -
196 -
197 if (d->state == QNetworkReplyHttpImplPrivate::Aborted ||
partially evaluated: d->state == QNetworkReplyHttpImplPrivate::Aborted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
198 d->state == QNetworkReplyHttpImplPrivate::Finished)
partially evaluated: d->state == QNetworkReplyHttpImplPrivate::Finished
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
199 return;
never executed: return;
0
200 -
201 -
202 -
203 QNetworkReply::close(); -
204 -
205 -
206 -
207 d->error(OperationCanceledError, tr("Operation canceled")); -
208 d->finished(); -
209}
executed: }
Execution Count:1
1
210 -
211void QNetworkReplyHttpImpl::abort() -
212{ -
213 QNetworkReplyHttpImplPrivate * const d = d_func(); -
214 -
215 if (d->state == QNetworkReplyHttpImplPrivate::Finished || d->state == QNetworkReplyHttpImplPrivate::Aborted)
evaluated: d->state == QNetworkReplyHttpImplPrivate::Finished
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: d->state == QNetworkReplyHttpImplPrivate::Aborted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
216 return;
executed: return;
Execution Count:1
1
217 -
218 QNetworkReply::close(); -
219 -
220 if (d->state != QNetworkReplyHttpImplPrivate::Finished) {
partially evaluated: d->state != QNetworkReplyHttpImplPrivate::Finished
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
221 -
222 -
223 d->error(OperationCanceledError, tr("Operation canceled")); -
224 d->finished(); -
225 }
executed: }
Execution Count:2
2
226 -
227 d->state = QNetworkReplyHttpImplPrivate::Aborted; -
228 -
229 abortHttpRequest(); -
230}
executed: }
Execution Count:2
2
231 -
232qint64 QNetworkReplyHttpImpl::bytesAvailable() const -
233{ -
234 const QNetworkReplyHttpImplPrivate * const d = d_func(); -
235 -
236 -
237 if (d->cacheLoadDevice) {
partially evaluated: d->cacheLoadDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5095
0-5095
238 return QNetworkReply::bytesAvailable() + d->cacheLoadDevice->bytesAvailable() + d->downloadMultiBuffer.byteAmount();
never executed: return QNetworkReply::bytesAvailable() + d->cacheLoadDevice->bytesAvailable() + d->downloadMultiBuffer.byteAmount();
0
239 } -
240 -
241 -
242 if (d->downloadZerocopyBuffer) {
evaluated: d->downloadZerocopyBuffer
TRUEFALSE
yes
Evaluation Count:2384
yes
Evaluation Count:2711
2384-2711
243 return QNetworkReply::bytesAvailable() + d->downloadBufferCurrentSize - d->downloadBufferReadPosition;
executed: return QNetworkReply::bytesAvailable() + d->downloadBufferCurrentSize - d->downloadBufferReadPosition;
Execution Count:2384
2384
244 } -
245 -
246 -
247 return QNetworkReply::bytesAvailable() + d->downloadMultiBuffer.byteAmount();
executed: return QNetworkReply::bytesAvailable() + d->downloadMultiBuffer.byteAmount();
Execution Count:2711
2711
248} -
249 -
250bool QNetworkReplyHttpImpl::isSequential () const -
251{ -
252 -
253 -
254 return true;
executed: return true;
Execution Count:467
467
255} -
256 -
257qint64 QNetworkReplyHttpImpl::size() const -
258{ -
259 -
260 return QNetworkReply::size();
executed: return QNetworkReply::size();
Execution Count:67
67
261} -
262 -
263qint64 QNetworkReplyHttpImpl::readData(char* data, qint64 maxlen) -
264{ -
265 QNetworkReplyHttpImplPrivate * const d = d_func(); -
266 -
267 -
268 if (d->cacheLoadDevice) {
partially evaluated: d->cacheLoadDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4107
0-4107
269 -
270 -
271 -
272 -
273 if (!d->downloadMultiBuffer.isEmpty()) {
never evaluated: !d->downloadMultiBuffer.isEmpty()
0
274 return d->downloadMultiBuffer.read(data, maxlen);
never executed: return d->downloadMultiBuffer.read(data, maxlen);
0
275 } -
276 -
277 qint64 ret = d->cacheLoadDevice->read(data, maxlen); -
278 return ret;
never executed: return ret;
0
279 } -
280 -
281 -
282 if (d->downloadZerocopyBuffer) {
evaluated: d->downloadZerocopyBuffer
TRUEFALSE
yes
Evaluation Count:1352
yes
Evaluation Count:2755
1352-2755
283 -
284 -
285 qint64 howMuch = qMin(maxlen, (d->downloadBufferCurrentSize - d->downloadBufferReadPosition)); -
286 memcpy(data, d->downloadZerocopyBuffer + d->downloadBufferReadPosition, howMuch); -
287 d->downloadBufferReadPosition += howMuch; -
288 return howMuch;
executed: return howMuch;
Execution Count:1352
1352
289 -
290 } -
291 -
292 -
293 if (d->downloadMultiBuffer.isEmpty()) {
evaluated: d->downloadMultiBuffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:1613
yes
Evaluation Count:1142
1142-1613
294 if (d->state == d->Finished || d->state == d->Aborted)
evaluated: d->state == d->Finished
TRUEFALSE
yes
Evaluation Count:350
yes
Evaluation Count:1263
partially evaluated: d->state == d->Aborted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1263
0-1263
295 return -1;
executed: return -1;
Execution Count:350
350
296 return 0;
executed: return 0;
Execution Count:1263
1263
297 } -
298 -
299 if (maxlen == 1) {
partially evaluated: maxlen == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1142
0-1142
300 -
301 *data = d->downloadMultiBuffer.getChar(); -
302 if (readBufferSize())
never evaluated: readBufferSize()
0
303 readBufferFreed(1);
never executed: readBufferFreed(1);
0
304 return 1;
never executed: return 1;
0
305 } -
306 -
307 maxlen = qMin<qint64>(maxlen, d->downloadMultiBuffer.byteAmount()); -
308 qint64 bytesRead = d->downloadMultiBuffer.read(data, maxlen); -
309 if (readBufferSize())
evaluated: readBufferSize()
TRUEFALSE
yes
Evaluation Count:883
yes
Evaluation Count:259
259-883
310 readBufferFreed(bytesRead);
executed: readBufferFreed(bytesRead);
Execution Count:883
883
311 return bytesRead;
executed: return bytesRead;
Execution Count:1142
1142
312} -
313 -
314void QNetworkReplyHttpImpl::setReadBufferSize(qint64 size) -
315{ -
316 QNetworkReply::setReadBufferSize(size); -
317 readBufferSizeChanged(size); -
318 return;
executed: return;
Execution Count:10
10
319} -
320 -
321bool QNetworkReplyHttpImpl::canReadLine () const -
322{ -
323 const QNetworkReplyHttpImplPrivate * const d = d_func(); -
324 -
325 if (QNetworkReply::canReadLine())
evaluated: QNetworkReply::canReadLine()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
326 return true;
executed: return true;
Execution Count:1
1
327 -
328 if (d->cacheLoadDevice)
partially evaluated: d->cacheLoadDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
329 return d->cacheLoadDevice->canReadLine() || d->downloadMultiBuffer.canReadLine();
never executed: return d->cacheLoadDevice->canReadLine() || d->downloadMultiBuffer.canReadLine();
0
330 -
331 if (d->downloadZerocopyBuffer)
partially evaluated: d->downloadZerocopyBuffer
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
332 return memchr(d->downloadZerocopyBuffer + d->downloadBufferReadPosition, '\n', d->downloadBufferCurrentSize - d->downloadBufferReadPosition);
executed: return memchr(d->downloadZerocopyBuffer + d->downloadBufferReadPosition, '\n', d->downloadBufferCurrentSize - d->downloadBufferReadPosition);
Execution Count:5
5
333 -
334 return d->downloadMultiBuffer.canReadLine();
never executed: return d->downloadMultiBuffer.canReadLine();
0
335} -
336 -
337 -
338void QNetworkReplyHttpImpl::ignoreSslErrors() -
339{ -
340 QNetworkReplyHttpImplPrivate * const d = d_func(); -
341 -
342 d->pendingIgnoreAllSslErrors = true; -
343}
executed: }
Execution Count:24
24
344 -
345void QNetworkReplyHttpImpl::ignoreSslErrorsImplementation(const QList<QSslError> &errors) -
346{ -
347 QNetworkReplyHttpImplPrivate * const d = d_func(); -
348 -
349 -
350 -
351 d->pendingIgnoreSslErrorsList = errors; -
352}
executed: }
Execution Count:10
10
353 -
354void QNetworkReplyHttpImpl::setSslConfigurationImplementation(const QSslConfiguration &newconfig) -
355{ -
356 -
357 -
358 (void)newconfig;; -
359}
never executed: }
0
360 -
361void QNetworkReplyHttpImpl::sslConfigurationImplementation(QSslConfiguration &configuration) const -
362{ -
363 const QNetworkReplyHttpImplPrivate * const d = d_func(); -
364 configuration = d->sslConfiguration; -
365}
executed: }
Execution Count:21
21
366 -
367 -
368QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate() -
369 : QNetworkReplyPrivate() -
370 , manager(0) -
371 , managerPrivate(0) -
372 , synchronous(false) -
373 , state(Idle) -
374 , statusCode(0) -
375 , outgoingData(0) -
376 , bytesUploaded(-1) -
377 , cacheLoadDevice(0) -
378 , loadingFromCache(false) -
379 , cacheSaveDevice(0) -
380 , cacheEnabled(false) -
381 , resumeOffset(0) -
382 , preMigrationDownloaded(-1) -
383 , bytesDownloaded(0) -
384 , downloadBufferReadPosition(0) -
385 , downloadBufferCurrentSize(0) -
386 , downloadZerocopyBuffer(0) -
387 , pendingDownloadDataEmissions(new QAtomicInt()) -
388 , pendingDownloadProgressEmissions(new QAtomicInt()) -
389 -
390 , pendingIgnoreAllSslErrors(false) -
391 -
392 -
393{ -
394}
executed: }
Execution Count:713
713
395 -
396QNetworkReplyHttpImplPrivate::~QNetworkReplyHttpImplPrivate() -
397{ -
398 QNetworkReplyHttpImpl * const q = q_func(); -
399 -
400 q->abortHttpRequest(); -
401}
executed: }
Execution Count:713
713
402 -
403 -
404 -
405 -
406 -
407 -
408 -
409bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &httpRequest) -
410{ -
411 QNetworkRequest::CacheLoadControl CacheLoadControlAttribute = -
412 (QNetworkRequest::CacheLoadControl)request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(); -
413 if (CacheLoadControlAttribute == QNetworkRequest::AlwaysNetwork) {
evaluated: CacheLoadControlAttribute == QNetworkRequest::AlwaysNetwork
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:507
12-507
414 -
415 -
416 if (!request.rawHeaderList().contains("Cache-Control")) {
partially evaluated: !request.rawHeaderList().contains("Cache-Control")
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
417 httpRequest.setHeaderField("Cache-Control", "no-cache"); -
418 httpRequest.setHeaderField("Pragma", "no-cache"); -
419 }
executed: }
Execution Count:12
12
420 return false;
executed: return false;
Execution Count:12
12
421 } -
422 -
423 -
424 -
425 if (request.hasRawHeader("Range"))
evaluated: request.hasRawHeader("Range")
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:505
2-505
426 return false;
executed: return false;
Execution Count:2
2
427 -
428 QAbstractNetworkCache *nc = managerPrivate->networkCache; -
429 if (!nc)
evaluated: !nc
TRUEFALSE
yes
Evaluation Count:419
yes
Evaluation Count:86
86-419
430 return false;
executed: return false;
Execution Count:419
419
431 -
432 QNetworkCacheMetaData metaData = nc->metaData(request.url()); -
433 if (!metaData.isValid())
evaluated: !metaData.isValid()
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:36
36-50
434 return false;
executed: return false;
Execution Count:50
50
435 -
436 if (!metaData.saveToDisk())
partially evaluated: !metaData.saveToDisk()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36
0-36
437 return false;
never executed: return false;
0
438 -
439 QNetworkHeadersPrivate cacheHeaders; -
440 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it; -
441 cacheHeaders.setAllRawHeaders(metaData.rawHeaders()); -
442 -
443 it = cacheHeaders.findRawHeader("etag"); -
444 if (it != cacheHeaders.rawHeaders.constEnd())
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:32
4-32
445 httpRequest.setHeaderField("If-None-Match", it->second);
executed: httpRequest.setHeaderField("If-None-Match", it->second);
Execution Count:4
4
446 -
447 QDateTime lastModified = metaData.lastModified(); -
448 if (lastModified.isValid())
evaluated: lastModified.isValid()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:14
14-22
449 httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
executed: httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
Execution Count:22
22
450 -
451 it = cacheHeaders.findRawHeader("Cache-Control"); -
452 if (it != cacheHeaders.rawHeaders.constEnd()) {
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:14
14-22
453 QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second); -
454 if (cacheControl.contains("must-revalidate"))
evaluated: cacheControl.contains("must-revalidate")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16
6-16
455 return false;
executed: return false;
Execution Count:6
6
456 }
executed: }
Execution Count:16
16
457 -
458 QDateTime currentDateTime = QDateTime::currentDateTime(); -
459 QDateTime expirationDate = metaData.expirationDate(); -
460 -
461 bool response_is_fresh; -
462 if (!expirationDate.isValid()) {
evaluated: !expirationDate.isValid()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:22
8-22
463 int age_value = 0; -
464 it = cacheHeaders.findRawHeader("age"); -
465 if (it != cacheHeaders.rawHeaders.constEnd())
partially evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
466 age_value = it->second.toInt();
never executed: age_value = it->second.toInt();
0
467 -
468 QDateTime dateHeader; -
469 int date_value = 0; -
470 it = cacheHeaders.findRawHeader("date"); -
471 if (it != cacheHeaders.rawHeaders.constEnd()) {
partially evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
472 dateHeader = QNetworkHeadersPrivate::fromHttpDate(it->second); -
473 date_value = dateHeader.toTime_t(); -
474 }
executed: }
Execution Count:8
8
475 -
476 int now = currentDateTime.toUTC().toTime_t(); -
477 int request_time = now; -
478 int response_time = now; -
479 -
480 -
481 int apparent_age = qMax(0, response_time - date_value); -
482 int corrected_received_age = qMax(apparent_age, age_value); -
483 int response_delay = response_time - request_time; -
484 int corrected_initial_age = corrected_received_age + response_delay; -
485 int resident_time = now - response_time; -
486 int current_age = corrected_initial_age + resident_time; -
487 -
488 -
489 if (!expirationDate.isValid()) {
partially evaluated: !expirationDate.isValid()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
490 if (lastModified.isValid()) {
evaluated: lastModified.isValid()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
491 int diff = currentDateTime.secsTo(lastModified); -
492 expirationDate = lastModified; -
493 expirationDate.addSecs(diff / 10); -
494 if (httpRequest.headerField("Warning").isEmpty()) {
partially evaluated: httpRequest.headerField("Warning").isEmpty()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
495 QDateTime dt; -
496 dt.setTime_t(current_age); -
497 if (dt.daysTo(currentDateTime) > 1)
partially evaluated: dt.daysTo(currentDateTime) > 1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
498 httpRequest.setHeaderField("Warning", "113");
executed: httpRequest.setHeaderField("Warning", "113");
Execution Count:4
4
499 }
executed: }
Execution Count:4
4
500 }
executed: }
Execution Count:4
4
501 }
executed: }
Execution Count:8
8
502 -
503 -
504 -
505 int freshness_lifetime = dateHeader.secsTo(expirationDate); -
506 response_is_fresh = (freshness_lifetime > current_age); -
507 } else {
executed: }
Execution Count:8
8
508 -
509 response_is_fresh = currentDateTime.secsTo(expirationDate) >= 0; -
510 }
executed: }
Execution Count:22
22
511 -
512 if (!response_is_fresh)
evaluated: !response_is_fresh
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:14
14-16
513 return false;
executed: return false;
Execution Count:16
16
514 -
515 -
516 -
517 -
518 return sendCacheContents(metaData);
executed: return sendCacheContents(metaData);
Execution Count:14
14
519} -
520 -
521QHttpNetworkRequest::Priority QNetworkReplyHttpImplPrivate::convert(const QNetworkRequest::Priority& prio) -
522{ -
523 switch (prio) { -
524 case QNetworkRequest::LowPriority: -
525 return QHttpNetworkRequest::LowPriority;
never executed: return QHttpNetworkRequest::LowPriority;
0
526 case QNetworkRequest::HighPriority: -
527 return QHttpNetworkRequest::HighPriority;
never executed: return QHttpNetworkRequest::HighPriority;
0
528 case QNetworkRequest::NormalPriority: -
529 default: -
530 return QHttpNetworkRequest::NormalPriority;
executed: return QHttpNetworkRequest::NormalPriority;
Execution Count:709
709
531 } -
532}
never executed: }
0
533 -
534void QNetworkReplyHttpImplPrivate::postRequest() -
535{ -
536 QNetworkReplyHttpImpl * const q = q_func(); -
537 -
538 QThread *thread = 0; -
539 if (synchronous) {
evaluated: synchronous
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:636
76-636
540 -
541 thread = new QThread(); -
542 thread->setObjectName(QString::fromUtf8("" "httpReply" "", sizeof("httpReply") - 1)); -
543 QObject::connect(thread, "2""finished()", thread, "1""deleteLater()"); -
544 thread->start(); -
545 } else if (!managerPrivate->httpThread) {
evaluated: !managerPrivate->httpThread
TRUEFALSE
yes
Evaluation Count:436
yes
Evaluation Count:200
executed: }
Execution Count:76
76-436
546 -
547 -
548 managerPrivate->httpThread = new QThread(); -
549 managerPrivate->httpThread->setObjectName(QString::fromUtf8("" "httpThread" "", sizeof("httpThread") - 1)); -
550 managerPrivate->httpThread->start(); -
551 -
552 thread = managerPrivate->httpThread; -
553 } else {
executed: }
Execution Count:436
436
554 -
555 thread = managerPrivate->httpThread; -
556 }
executed: }
Execution Count:200
200
557 -
558 QUrl url = request.url(); -
559 httpRequest.setUrl(url); -
560 -
561 bool ssl = url.scheme().toLower() == QLatin1String("https"); -
562 q->setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, ssl); -
563 httpRequest.setSsl(ssl); -
564 -
565 -
566 -
567 QNetworkProxy transparentProxy, cacheProxy; -
568 -
569 -
570 for (QForeachContainer<__typeof__(managerPrivate->queryProxy(QNetworkProxyQuery(request.url())))> _container_(managerPrivate->queryProxy(QNetworkProxyQuery(request.url()))); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QNetworkProxy &p = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
571 -
572 -
573 -
574 if (!ssl
evaluated: !ssl
TRUEFALSE
yes
Evaluation Count:625
yes
Evaluation Count:92
92-625
575 && (p.capabilities() & QNetworkProxy::CachingCapability)
evaluated: (p.capabilities() & QNetworkProxy::CachingCapability)
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:565
60-565
576 && (p.type() == QNetworkProxy::HttpProxy ||
evaluated: p.type() == QNetworkProxy::HttpProxy
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:11
11-49
577 p.type() == QNetworkProxy::HttpCachingProxy)) {
evaluated: p.type() == QNetworkProxy::HttpCachingProxy
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3
3-8
578 cacheProxy = p; -
579 transparentProxy = QNetworkProxy::NoProxy; -
580 break;
executed: break;
Execution Count:57
57
581 } -
582 if (p.isTransparentProxy()) {
evaluated: p.isTransparentProxy()
TRUEFALSE
yes
Evaluation Count:652
yes
Evaluation Count:8
8-652
583 transparentProxy = p; -
584 cacheProxy = QNetworkProxy::NoProxy; -
585 break;
executed: break;
Execution Count:652
652
586 } -
587 }
executed: }
Execution Count:8
8
588 -
589 -
590 if (transparentProxy.type() == QNetworkProxy::DefaultProxy &&
evaluated: transparentProxy.type() == QNetworkProxy::DefaultProxy
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:709
3-709
591 cacheProxy.type() == QNetworkProxy::DefaultProxy) {
partially evaluated: cacheProxy.type() == QNetworkProxy::DefaultProxy
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
592 -
593 QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection, -
594 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::ProxyNotFoundError), -
595 QArgument<QString >("QString", QNetworkReplyHttpImpl::tr("No suitable proxy found"))); -
596 QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); -
597 return;
executed: return;
Execution Count:3
3
598 } -
599 -
600 -
601 -
602 bool loadedFromCache = false; -
603 httpRequest.setPriority(convert(request.priority())); -
604 -
605 switch (operation) { -
606 case QNetworkAccessManager::GetOperation: -
607 httpRequest.setOperation(QHttpNetworkRequest::Get); -
608 loadedFromCache = loadFromCacheIfAllowed(httpRequest); -
609 break;
executed: break;
Execution Count:493
493
610 -
611 case QNetworkAccessManager::HeadOperation: -
612 httpRequest.setOperation(QHttpNetworkRequest::Head); -
613 loadedFromCache = loadFromCacheIfAllowed(httpRequest); -
614 break;
executed: break;
Execution Count:26
26
615 -
616 case QNetworkAccessManager::PostOperation: -
617 invalidateCache(); -
618 httpRequest.setOperation(QHttpNetworkRequest::Post); -
619 createUploadByteDevice(); -
620 break;
executed: break;
Execution Count:142
142
621 -
622 case QNetworkAccessManager::PutOperation: -
623 invalidateCache(); -
624 httpRequest.setOperation(QHttpNetworkRequest::Put); -
625 createUploadByteDevice(); -
626 break;
executed: break;
Execution Count:35
35
627 -
628 case QNetworkAccessManager::DeleteOperation: -
629 invalidateCache(); -
630 httpRequest.setOperation(QHttpNetworkRequest::Delete); -
631 break;
executed: break;
Execution Count:7
7
632 -
633 case QNetworkAccessManager::CustomOperation: -
634 invalidateCache(); -
635 httpRequest.setOperation(QHttpNetworkRequest::Custom); -
636 createUploadByteDevice(); -
637 httpRequest.setCustomVerb(request.attribute( -
638 QNetworkRequest::CustomVerbAttribute).toByteArray()); -
639 break;
executed: break;
Execution Count:6
6
640 -
641 default: -
642 break;
never executed: break;
0
643 } -
644 -
645 if (loadedFromCache) {
evaluated: loadedFromCache
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:695
14-695
646 return;
executed: return;
Execution Count:14
14
647 } -
648 -
649 QList<QByteArray> headers = request.rawHeaderList(); -
650 if (resumeOffset != 0) {
partially evaluated: resumeOffset != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:695
0-695
651 if (headers.contains("Range")) {
never evaluated: headers.contains("Range")
0
652 -
653 -
654 headers.removeOne("Range"); -
655 -
656 -
657 QByteArray requestRange = request.rawHeader("Range").mid(6); -
658 -
659 int index = requestRange.indexOf('-'); -
660 -
661 quint64 requestStartOffset = requestRange.left(index).toULongLong(); -
662 quint64 requestEndOffset = requestRange.mid(index + 1).toULongLong(); -
663 -
664 requestRange = "bytes=" + QByteArray::number(resumeOffset + requestStartOffset) + -
665 '-' + QByteArray::number(requestEndOffset); -
666 -
667 httpRequest.setHeaderField("Range", requestRange); -
668 } else {
never executed: }
0
669 httpRequest.setHeaderField("Range", "bytes=" + QByteArray::number(resumeOffset) + '-'); -
670 }
never executed: }
0
671 } -
672 -
673 for (QForeachContainer<__typeof__(headers)> _container_(headers); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QByteArray &header = *_container_.i;; __extension__ ({--_container_.brk; break;})) -
674 httpRequest.setHeaderField(header, request.rawHeader(header));
executed: httpRequest.setHeaderField(header, request.rawHeader(header));
Execution Count:295
295
675 -
676 if (request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool() == true)
evaluated: request.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool() == true
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:675
20-675
677 httpRequest.setPipeliningAllowed(true);
executed: httpRequest.setPipeliningAllowed(true);
Execution Count:20
20
678 -
679 if (static_cast<QNetworkRequest::LoadControl> 1-694
680 (request.attribute(QNetworkRequest::AuthenticationReuseAttribute, 1-694
681 QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
evaluated: static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:694
1-694
682 httpRequest.setWithCredentials(false);
executed: httpRequest.setWithCredentials(false);
Execution Count:1
1
683 -
684 -
685 -
686 QHttpThreadDelegate *delegate = new QHttpThreadDelegate; -
687 -
688 delegate->networkSession = managerPrivate->getNetworkSession(); -
689 -
690 -
691 -
692 -
693 QObject::connect(thread, "2""finished()", delegate, "1""deleteLater()"); -
694 -
695 -
696 delegate->httpRequest = httpRequest; -
697 -
698 delegate->cacheProxy = cacheProxy; -
699 delegate->transparentProxy = transparentProxy; -
700 -
701 delegate->ssl = ssl; -
702 -
703 if (ssl)
evaluated: ssl
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:608
87-608
704 delegate->incomingSslConfiguration = request.sslConfiguration();
executed: delegate->incomingSslConfiguration = request.sslConfiguration();
Execution Count:87
87
705 -
706 -
707 -
708 delegate->synchronous = synchronous; -
709 -
710 -
711 -
712 delegate->authenticationManager = managerPrivate->authenticationManager; -
713 -
714 if (!synchronous) {
evaluated: !synchronous
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:76
76-619
715 -
716 QVariant downloadBufferMaximumSizeAttribute = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute); -
717 if (downloadBufferMaximumSizeAttribute.isValid()) {
evaluated: downloadBufferMaximumSizeAttribute.isValid()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:616
3-616
718 delegate->downloadBufferMaximumSize = downloadBufferMaximumSizeAttribute.toLongLong(); -
719 } else {
executed: }
Execution Count:3
3
720 -
721 -
722 -
723 delegate->downloadBufferMaximumSize = 128*1024; -
724 }
executed: }
Execution Count:616
616
725 -
726 -
727 -
728 delegate->pendingDownloadData = pendingDownloadDataEmissions; -
729 delegate->pendingDownloadProgress = pendingDownloadProgressEmissions; -
730 -
731 -
732 QObject::connect(delegate, "2""downloadData(QByteArray)", -
733 q, "1""replyDownloadData(QByteArray)", -
734 Qt::QueuedConnection); -
735 QObject::connect(delegate, "2""downloadFinished()", -
736 q, "1""replyFinished()", -
737 Qt::QueuedConnection); -
738 QObject::connect(delegate, "2""downloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64)", -
739 q, "1""replyDownloadMetaData(QList<QPair<QByteArray,QByteArray> >,int,QString,bool,QSharedPointer<char>,qint64)", -
740 Qt::QueuedConnection); -
741 QObject::connect(delegate, "2""downloadProgress(qint64,qint64)", -
742 q, "1""replyDownloadProgressSlot(qint64,qint64)", -
743 Qt::QueuedConnection); -
744 QObject::connect(delegate, "2""error(QNetworkReply::NetworkError,QString)", -
745 q, "1""httpError(QNetworkReply::NetworkError,QString)", -
746 Qt::QueuedConnection); -
747 -
748 QObject::connect(delegate, "2""sslConfigurationChanged(QSslConfiguration)", -
749 q, "1""replySslConfigurationChanged(QSslConfiguration)", -
750 Qt::QueuedConnection); -
751 -
752 -
753 QObject::connect(delegate, "2""authenticationRequired(QHttpNetworkRequest,QAuthenticator*)", -
754 q, "1""httpAuthenticationRequired(QHttpNetworkRequest,QAuthenticator*)", -
755 Qt::BlockingQueuedConnection); -
756 -
757 QObject::connect(delegate, "2""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)", -
758 q, "1""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)", -
759 Qt::BlockingQueuedConnection); -
760 -
761 -
762 QObject::connect(delegate, "2""sslErrors(QList<QSslError>,bool*,QList<QSslError>*)", -
763 q, "1""replySslErrors(QList<QSslError>,bool*,QList<QSslError>*)", -
764 Qt::BlockingQueuedConnection); -
765 -
766 -
767 QObject::connect(q, "2""startHttpRequest()", delegate, "1""startRequest()"); -
768 QObject::connect(q, "2""abortHttpRequest()", delegate, "1""abortRequest()"); -
769 -
770 -
771 QObject::connect(q, "2""readBufferSizeChanged(qint64)", delegate, "1""readBufferSizeChanged(qint64)"); -
772 QObject::connect(q, "2""readBufferFreed(qint64)", delegate, "1""readBufferFreed(qint64)"); -
773 -
774 if (uploadByteDevice) {
evaluated: uploadByteDevice
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:481
138-481
775 QNonContiguousByteDeviceThreadForwardImpl *forwardUploadDevice = -
776 new QNonContiguousByteDeviceThreadForwardImpl(uploadByteDevice->atEnd(), uploadByteDevice->size()); -
777 if (uploadByteDevice->isResetDisabled())
evaluated: uploadByteDevice->isResetDisabled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:137
1-137
778 forwardUploadDevice->disableReset();
executed: forwardUploadDevice->disableReset();
Execution Count:1
1
779 forwardUploadDevice->setParent(delegate); -
780 delegate->httpRequest.setUploadByteDevice(forwardUploadDevice); -
781 -
782 -
783 QObject::connect(q, "2""haveUploadData(QByteArray,bool,qint64)", -
784 forwardUploadDevice, "1""haveDataSlot(QByteArray,bool,qint64)", Qt::QueuedConnection); -
785 QObject::connect(uploadByteDevice.data(), "2""readyRead()", -
786 forwardUploadDevice, "2""readyRead()", -
787 Qt::QueuedConnection); -
788 -
789 -
790 QObject::connect(forwardUploadDevice, "2""wantData(qint64)", -
791 q, "1""wantUploadDataSlot(qint64)"); -
792 QObject::connect(forwardUploadDevice, "2""processedData(qint64)", -
793 q, "1""sentUploadDataSlot(qint64)"); -
794 QObject::connect(forwardUploadDevice, "2""resetData(bool*)", -
795 q, "1""resetUploadDataSlot(bool*)", -
796 Qt::BlockingQueuedConnection); -
797 }
executed: }
Execution Count:138
138
798 } else if (synchronous) {
executed: }
Execution Count:619
partially evaluated: synchronous
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-619
799 QObject::connect(q, "2""startHttpRequestSynchronously()", delegate, "1""startRequestSynchronously()", Qt::BlockingQueuedConnection); -
800 -
801 if (uploadByteDevice) {
evaluated: uploadByteDevice
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:35
35-41
802 -
803 -
804 -
805 -
806 -
807 -
808 delegate->httpRequest.setUploadByteDevice(uploadByteDevice.data()); -
809 }
executed: }
Execution Count:41
41
810 }
executed: }
Execution Count:76
76
811 -
812 -
813 -
814 delegate->moveToThread(thread); -
815 -
816 -
817 -
818 downloadProgressSignalChoke.start(); -
819 uploadProgressSignalChoke.invalidate(); -
820 -
821 -
822 if (synchronous) {
evaluated: synchronous
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:619
76-619
823 q->startHttpRequestSynchronously(); -
824 -
825 if (delegate->incomingErrorCode != QNetworkReply::NoError) {
evaluated: delegate->incomingErrorCode != QNetworkReply::NoError
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:63
13-63
826 replyDownloadMetaData -
827 (delegate->incomingHeaders, -
828 delegate->incomingStatusCode, -
829 delegate->incomingReasonPhrase, -
830 delegate->isPipeliningUsed, -
831 QSharedPointer<char>(), -
832 delegate->incomingContentLength); -
833 replyDownloadData(delegate->synchronousDownloadData); -
834 httpError(delegate->incomingErrorCode, delegate->incomingErrorDetail); -
835 } else {
executed: }
Execution Count:13
13
836 replyDownloadMetaData -
837 (delegate->incomingHeaders, -
838 delegate->incomingStatusCode, -
839 delegate->incomingReasonPhrase, -
840 delegate->isPipeliningUsed, -
841 QSharedPointer<char>(), -
842 delegate->incomingContentLength); -
843 replyDownloadData(delegate->synchronousDownloadData); -
844 }
executed: }
Execution Count:63
63
845 -
846 thread->quit(); -
847 thread->wait(5000); -
848 if (thread->isFinished())
partially evaluated: thread->isFinished()
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
849 delete thread;
executed: delete thread;
Execution Count:76
76
850 else -
851 QObject::connect(thread, "2""finished()", thread, "1""deleteLater()");
never executed: QObject::connect(thread, "2""finished()", thread, "1""deleteLater()");
0
852 -
853 finished(); -
854 } else {
executed: }
Execution Count:76
76
855 q->startHttpRequest(); -
856 }
executed: }
Execution Count:619
619
857} -
858 -
859void QNetworkReplyHttpImplPrivate::invalidateCache() -
860{ -
861 QAbstractNetworkCache *nc = managerPrivate->networkCache; -
862 if (nc)
evaluated: nc
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:188
2-188
863 nc->remove(request.url());
executed: nc->remove(request.url());
Execution Count:2
2
864}
executed: }
Execution Count:190
190
865 -
866void QNetworkReplyHttpImplPrivate::initCacheSaveDevice() -
867{ -
868 QNetworkReplyHttpImpl * const q = q_func(); -
869 -
870 -
871 -
872 if (q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206) {
evaluated: q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:62
1-62
873 cacheEnabled = false; -
874 return;
executed: return;
Execution Count:1
1
875 } -
876 -
877 -
878 QNetworkCacheMetaData metaData; -
879 metaData.setUrl(url); -
880 metaData = fetchCacheMetaData(metaData); -
881 -
882 -
883 QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); -
884 if (redirectionTarget.isValid()) {
partially evaluated: redirectionTarget.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
0-62
885 QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); -
886 attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); -
887 metaData.setAttributes(attributes); -
888 }
never executed: }
0
889 -
890 cacheSaveDevice = managerPrivate->networkCache->prepare(metaData); -
891 -
892 if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
evaluated: !cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:55
partially evaluated: cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:55
no
Evaluation Count:0
partially evaluated: !cacheSaveDevice->isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
0-55
893 if (cacheSaveDevice && !cacheSaveDevice->isOpen())
partially evaluated: cacheSaveDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
never evaluated: !cacheSaveDevice->isOpen()
0-7
894 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 965, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " 0
895 "class %s probably needs to be fixed", 0
896 managerPrivate->networkCache->metaObject()->className());
never executed: QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 965, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " "class %s probably needs to be fixed", managerPrivate->networkCache->metaObject()->className());
0
897 -
898 managerPrivate->networkCache->remove(url); -
899 cacheSaveDevice = 0; -
900 cacheEnabled = false; -
901 }
executed: }
Execution Count:7
7
902}
executed: }
Execution Count:62
62
903 -
904void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d) -
905{ -
906 QNetworkReplyHttpImpl * const q = q_func(); -
907 -
908 -
909 if (!q->isOpen())
evaluated: !q->isOpen()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6578
2-6578
910 return;
executed: return;
Execution Count:2
2
911 -
912 int pendingSignals = (int)pendingDownloadDataEmissions->fetchAndAddAcquire(-1) - 1; -
913 -
914 if (pendingSignals > 0) {
evaluated: pendingSignals > 0
TRUEFALSE
yes
Evaluation Count:681
yes
Evaluation Count:5897
681-5897
915 -
916 -
917 -
918 -
919 pendingDownloadData.append(d); -
920 return;
executed: return;
Execution Count:681
681
921 } -
922 -
923 pendingDownloadData.append(d); -
924 d.clear(); -
925 -
926 -
927 -
928 -
929 QByteDataBuffer pendingDownloadDataCopy = pendingDownloadData; -
930 pendingDownloadData.clear(); -
931 -
932 if (cacheEnabled && isCachingAllowed() && !cacheSaveDevice) {
evaluated: cacheEnabled
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:5850
partially evaluated: isCachingAllowed()
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
partially evaluated: !cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
0-5850
933 initCacheSaveDevice(); -
934 }
executed: }
Execution Count:47
47
935 -
936 qint64 bytesWritten = 0; -
937 for (int i = 0; i < pendingDownloadDataCopy.bufferCount(); i++) {
evaluated: i < pendingDownloadDataCopy.bufferCount()
TRUEFALSE
yes
Evaluation Count:6565
yes
Evaluation Count:5897
5897-6565
938 QByteArray const &item = pendingDownloadDataCopy[i]; -
939 -
940 if (cacheSaveDevice)
evaluated: cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:6519
46-6519
941 cacheSaveDevice->write(item.constData(), item.size());
executed: cacheSaveDevice->write(item.constData(), item.size());
Execution Count:46
46
942 downloadMultiBuffer.append(item); -
943 -
944 bytesWritten += item.size(); -
945 }
executed: }
Execution Count:6565
6565
946 pendingDownloadDataCopy.clear(); -
947 -
948 bytesDownloaded += bytesWritten; -
949 -
950 -
951 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); -
952 if (preMigrationDownloaded != static_cast<long long>(-1LL))
partially evaluated: preMigrationDownloaded != static_cast<long long>(-1LL)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5897
0-5897
953 totalSize = totalSize.toLongLong() + preMigrationDownloaded;
never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded;
0
954 -
955 q->readyRead(); -
956 -
957 -
958 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval
TRUEFALSE
yes
Evaluation Count:153
yes
Evaluation Count:5744
153-5744
959 downloadProgressSignalChoke.restart(); -
960 q->downloadProgress(bytesDownloaded, -
961 totalSize.isNull() ? static_cast<long long>(-1LL) : totalSize.toLongLong()); -
962 }
executed: }
Execution Count:153
153
963 -
964}
executed: }
Execution Count:5897
5897
965 -
966void QNetworkReplyHttpImplPrivate::replyFinished() -
967{ -
968 -
969 -
970 if (loadingFromCache)
evaluated: loadingFromCache
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:589
11-589
971 return;
executed: return;
Execution Count:11
11
972 -
973 finished(); -
974}
executed: }
Execution Count:589
589
975 -
976void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode) -
977{ -
978 QNetworkReplyHttpImpl * const q = q_func(); -
979 switch (statusCode) { -
980 case 301: -
981 case 302: -
982 case 303: -
983 case 307: -
984 -
985 -
986 -
987 QByteArray header = q->rawHeader("location"); -
988 QUrl url = QUrl(QString::fromUtf8(header)); -
989 if (!url.isValid())
never evaluated: !url.isValid()
0
990 url = QUrl(QLatin1String(header));
never executed: url = QUrl(QLatin1String(header));
0
991 q->setAttribute(QNetworkRequest::RedirectionTargetAttribute, url); -
992 }
never executed: }
0
993}
executed: }
Execution Count:664
664
994 -
995void QNetworkReplyHttpImplPrivate::replyDownloadMetaData -
996 (QList<QPair<QByteArray,QByteArray> > hm, -
997 int sc,QString rp,bool pu, -
998 QSharedPointer<char> db, -
999 qint64 contentLength) -
1000{ -
1001 QNetworkReplyHttpImpl * const q = q_func(); -
1002 (void)contentLength;; -
1003 -
1004 statusCode = sc; -
1005 reasonPhrase = rp; -
1006 -
1007 -
1008 if (!db.isNull()) {
evaluated: !db.isNull()
TRUEFALSE
yes
Evaluation Count:333
yes
Evaluation Count:306
306-333
1009 downloadBufferPointer = db; -
1010 downloadZerocopyBuffer = downloadBufferPointer.data(); -
1011 downloadBufferCurrentSize = 0; -
1012 q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer)); -
1013 }
executed: }
Execution Count:333
333
1014 -
1015 q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); -
1016 -
1017 -
1018 QList<QPair<QByteArray, QByteArray> > headerMap = hm; -
1019 QList<QPair<QByteArray, QByteArray> >::ConstIterator it = headerMap.constBegin(), -
1020 end = headerMap.constEnd(); -
1021 for (; it != end; ++it) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:4216
yes
Evaluation Count:639
639-4216
1022 QByteArray value = q->rawHeader(it->first); -
1023 if (!value.isEmpty()) {
evaluated: !value.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4213
3-4213
1024 if (qstricmp(it->first.constData(), "set-cookie") == 0)
evaluated: qstricmp(it->first.constData(), "set-cookie") == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
1025 value += '\n';
executed: value += '\n';
Execution Count:2
2
1026 else -
1027 value += ", ";
executed: value += ", ";
Execution Count:1
1
1028 } -
1029 value += it->second; -
1030 q->setRawHeader(it->first, value); -
1031 }
executed: }
Execution Count:4216
4216
1032 -
1033 q->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, statusCode); -
1034 q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase); -
1035 -
1036 -
1037 checkForRedirect(statusCode); -
1038 -
1039 if (statusCode >= 500 && statusCode < 600) {
evaluated: statusCode >= 500
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:638
partially evaluated: statusCode < 600
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-638
1040 QAbstractNetworkCache *nc = managerPrivate->networkCache; -
1041 if (nc) {
partially evaluated: nc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1042 QNetworkCacheMetaData metaData = nc->metaData(request.url()); -
1043 QNetworkHeadersPrivate cacheHeaders; -
1044 cacheHeaders.setAllRawHeaders(metaData.rawHeaders()); -
1045 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it; -
1046 it = cacheHeaders.findRawHeader("Cache-Control"); -
1047 bool mustReValidate = false; -
1048 if (it != cacheHeaders.rawHeaders.constEnd()) {
never evaluated: it != cacheHeaders.rawHeaders.constEnd()
0
1049 QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second); -
1050 if (cacheControl.contains("must-revalidate"))
never evaluated: cacheControl.contains("must-revalidate")
0
1051 mustReValidate = true;
never executed: mustReValidate = true;
0
1052 }
never executed: }
0
1053 if (!mustReValidate && sendCacheContents(metaData))
never evaluated: !mustReValidate
never evaluated: sendCacheContents(metaData)
0
1054 return;
never executed: return;
0
1055 }
never executed: }
0
1056 }
executed: }
Execution Count:1
1
1057 -
1058 if (statusCode == 304) {
evaluated: statusCode == 304
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:628
11-628
1059 -
1060 -
1061 -
1062 QAbstractNetworkCache *nc = managerPrivate->networkCache; -
1063 if (nc) {
partially evaluated: nc
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1064 QNetworkCacheMetaData oldMetaData = nc->metaData(request.url()); -
1065 QNetworkCacheMetaData metaData = fetchCacheMetaData(oldMetaData); -
1066 if (oldMetaData != metaData)
partially evaluated: oldMetaData != metaData
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1067 nc->updateMetaData(metaData);
executed: nc->updateMetaData(metaData);
Execution Count:11
11
1068 if (sendCacheContents(metaData))
partially evaluated: sendCacheContents(metaData)
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1069 return;
executed: return;
Execution Count:11
11
1070 }
never executed: }
0
1071 }
never executed: }
0
1072 -
1073 -
1074 if (statusCode != 304 && statusCode != 303) {
partially evaluated: statusCode != 304
TRUEFALSE
yes
Evaluation Count:628
no
Evaluation Count:0
partially evaluated: statusCode != 303
TRUEFALSE
yes
Evaluation Count:628
no
Evaluation Count:0
0-628
1075 if (!isCachingEnabled())
partially evaluated: !isCachingEnabled()
TRUEFALSE
yes
Evaluation Count:628
no
Evaluation Count:0
0-628
1076 setCachingEnabled(true);
executed: setCachingEnabled(true);
Execution Count:628
628
1077 }
executed: }
Execution Count:628
628
1078 -
1079 metaDataChanged(); -
1080}
executed: }
Execution Count:628
628
1081 -
1082void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceived, qint64 bytesTotal) -
1083{ -
1084 QNetworkReplyHttpImpl * const q = q_func(); -
1085 -
1086 -
1087 if (!q->isOpen())
partially evaluated: !q->isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3161
0-3161
1088 return;
never executed: return;
0
1089 -
1090 -
1091 -
1092 int pendingSignals = (int)pendingDownloadProgressEmissions->fetchAndAddAcquire(-1) - 1; -
1093 if (pendingSignals > 0) {
evaluated: pendingSignals > 0
TRUEFALSE
yes
Evaluation Count:500
yes
Evaluation Count:2661
500-2661
1094 -
1095 -
1096 return;
executed: return;
Execution Count:500
500
1097 } -
1098 -
1099 if (!q->isOpen())
partially evaluated: !q->isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2661
0-2661
1100 return;
never executed: return;
0
1101 -
1102 if (cacheEnabled && isCachingAllowed() && bytesReceived == bytesTotal) {
evaluated: cacheEnabled
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:2643
evaluated: isCachingAllowed()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:1
evaluated: bytesReceived == bytesTotal
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:1
1-2643
1103 -
1104 initCacheSaveDevice(); -
1105 -
1106 if (cacheSaveDevice && cacheEnabled)
evaluated: cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:7
partially evaluated: cacheEnabled
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1107 cacheSaveDevice->write(downloadZerocopyBuffer, bytesTotal);
executed: cacheSaveDevice->write(downloadZerocopyBuffer, bytesTotal);
Execution Count:9
9
1108 -
1109 }
executed: }
Execution Count:16
16
1110 -
1111 bytesDownloaded = bytesReceived; -
1112 -
1113 downloadBufferCurrentSize = bytesReceived; -
1114 -
1115 -
1116 -
1117 -
1118 if (bytesDownloaded > 0)
partially evaluated: bytesDownloaded > 0
TRUEFALSE
yes
Evaluation Count:2661
no
Evaluation Count:0
0-2661
1119 q->readyRead();
executed: q->readyRead();
Execution Count:2661
2661
1120 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:2604
57-2604
1121 downloadProgressSignalChoke.restart(); -
1122 q->downloadProgress(bytesDownloaded, bytesTotal); -
1123 }
executed: }
Execution Count:57
57
1124}
executed: }
Execution Count:2661
2661
1125 -
1126void QNetworkReplyHttpImplPrivate::httpAuthenticationRequired(const QHttpNetworkRequest &request, -
1127 QAuthenticator *auth) -
1128{ -
1129 managerPrivate->authenticationRequired(auth, q_func(), synchronous, url, &urlForLastAuthentication, request.withCredentials()); -
1130}
executed: }
Execution Count:113
113
1131 -
1132 -
1133void QNetworkReplyHttpImplPrivate::proxyAuthenticationRequired(const QNetworkProxy &proxy, -
1134 QAuthenticator *authenticator) -
1135{ -
1136 managerPrivate->proxyAuthenticationRequired(proxy, synchronous, authenticator, &lastProxyAuthentication); -
1137}
executed: }
Execution Count:61
61
1138 -
1139 -
1140void QNetworkReplyHttpImplPrivate::httpError(QNetworkReply::NetworkError errorCode, -
1141 const QString &errorString) -
1142{ -
1143 -
1144 -
1145 -
1146 -
1147 -
1148 error(errorCode, errorString); -
1149}
executed: }
Execution Count:87
87
1150 -
1151 -
1152void QNetworkReplyHttpImplPrivate::replySslErrors( -
1153 const QList<QSslError> &list, bool *ignoreAll, QList<QSslError> *toBeIgnored) -
1154{ -
1155 QNetworkReplyHttpImpl * const q = q_func(); -
1156 q->sslErrors(list); -
1157 -
1158 if (pendingIgnoreAllSslErrors)
evaluated: pendingIgnoreAllSslErrors
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:12
12-21
1159 *ignoreAll = true;
executed: *ignoreAll = true;
Execution Count:21
21
1160 if (!pendingIgnoreSslErrorsList.isEmpty())
evaluated: !pendingIgnoreSslErrorsList.isEmpty()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:27
6-27
1161 *toBeIgnored = pendingIgnoreSslErrorsList;
executed: *toBeIgnored = pendingIgnoreSslErrorsList;
Execution Count:6
6
1162}
executed: }
Execution Count:33
33
1163 -
1164void QNetworkReplyHttpImplPrivate::replySslConfigurationChanged(const QSslConfiguration &sslConfiguration) -
1165{ -
1166 -
1167 this->sslConfiguration = sslConfiguration; -
1168}
executed: }
Execution Count:159
159
1169 -
1170 -
1171 -
1172void QNetworkReplyHttpImplPrivate::resetUploadDataSlot(bool *r) -
1173{ -
1174 *r = uploadByteDevice->reset(); -
1175}
executed: }
Execution Count:137
137
1176 -
1177 -
1178void QNetworkReplyHttpImplPrivate::sentUploadDataSlot(qint64 amount) -
1179{ -
1180 uploadByteDevice->advanceReadPointer(amount); -
1181}
executed: }
Execution Count:1875
1875
1182 -
1183 -
1184void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize) -
1185{ -
1186 QNetworkReplyHttpImpl * const q = q_func(); -
1187 -
1188 -
1189 qint64 currentUploadDataLength = 0; -
1190 char *data = const_cast<char*>(uploadByteDevice->readPointer(maxSize, currentUploadDataLength)); -
1191 -
1192 QByteArray dataArray(data, currentUploadDataLength); -
1193 -
1194 -
1195 q->haveUploadData(dataArray, uploadByteDevice->atEnd(), uploadByteDevice->size()); -
1196}
executed: }
Execution Count:1876
1876
1197 -
1198 -
1199 -
1200 -
1201bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData &metaData) -
1202{ -
1203 QNetworkReplyHttpImpl * const q = q_func(); -
1204 -
1205 setCachingEnabled(false); -
1206 if (!metaData.isValid())
partially evaluated: !metaData.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1207 return false;
never executed: return false;
0
1208 -
1209 QAbstractNetworkCache *nc = managerPrivate->networkCache; -
1210 qt_noop(); -
1211 QIODevice *contents = nc->data(url); -
1212 if (!contents) {
partially evaluated: !contents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1213 -
1214 -
1215 -
1216 return false;
never executed: return false;
0
1217 } -
1218 contents->setParent(q); -
1219 -
1220 QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); -
1221 int status = attributes.value(QNetworkRequest::HttpStatusCodeAttribute).toInt(); -
1222 if (status < 100)
evaluated: status < 100
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:17
8-17
1223 status = 200;
executed: status = 200;
Execution Count:8
8
1224 -
1225 q->setAttribute(QNetworkRequest::HttpStatusCodeAttribute, status); -
1226 q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); -
1227 q->setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); -
1228 -
1229 QNetworkCacheMetaData::RawHeaderList rawHeaders = metaData.rawHeaders(); -
1230 QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), -
1231 end = rawHeaders.constEnd(); -
1232 for ( ; it != end; ++it)
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:25
25-92
1233 setRawHeader(it->first, it->second);
executed: setRawHeader(it->first, it->second);
Execution Count:92
92
1234 -
1235 checkForRedirect(status); -
1236 -
1237 cacheLoadDevice = contents; -
1238 q->connect(cacheLoadDevice, "2""readyRead()", "1""_q_cacheLoadReadyRead()"); -
1239 q->connect(cacheLoadDevice, "2""readChannelFinished()", "1""_q_cacheLoadReadyRead()"); -
1240 -
1241 -
1242 -
1243 -
1244 QMetaObject::invokeMethod(q, "metaDataChanged", Qt::QueuedConnection); -
1245 QMetaObject::invokeMethod(q, "_q_cacheLoadReadyRead", Qt::QueuedConnection); -
1246 loadingFromCache = true; -
1247 return true;
executed: return true;
Execution Count:25
25
1248} -
1249 -
1250QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNetworkCacheMetaData &oldMetaData) const -
1251{ -
1252 const QNetworkReplyHttpImpl * const q = q_func(); -
1253 -
1254 QNetworkCacheMetaData metaData = oldMetaData; -
1255 -
1256 QNetworkHeadersPrivate cacheHeaders; -
1257 cacheHeaders.setAllRawHeaders(metaData.rawHeaders()); -
1258 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it; -
1259 -
1260 QList<QByteArray> newHeaders = q->rawHeaderList(); -
1261 for (QForeachContainer<__typeof__(newHeaders)> _container_(newHeaders); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QByteArray header = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
1262 QByteArray originalHeader = header; -
1263 header = header.toLower(); -
1264 bool hop_by_hop = -
1265 (header == "connection"
evaluated: header == "connection"
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:404
73-404
1266 || header == "keep-alive"
evaluated: header == "keep-alive"
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:338
66-338
1267 || header == "proxy-authenticate"
partially evaluated: header == "proxy-authenticate"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
1268 || header == "proxy-authorization"
partially evaluated: header == "proxy-authorization"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
1269 || header == "te"
partially evaluated: header == "te"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
1270 || header == "trailers"
partially evaluated: header == "trailers"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:338
0-338
1271 || header == "transfer-encoding"
evaluated: header == "transfer-encoding"
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:295
43-295
1272 || header == "upgrade");
partially evaluated: header == "upgrade"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:295
0-295
1273 if (hop_by_hop)
evaluated: hop_by_hop
TRUEFALSE
yes
Evaluation Count:182
yes
Evaluation Count:295
182-295
1274 continue;
executed: continue;
Execution Count:182
182
1275 if (header == "warning") {
partially evaluated: header == "warning"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:295
0-295
1276 QByteArray v = q->rawHeader(header); -
1277 if (v.length() == 3
never evaluated: v.length() == 3
0
1278 && v[0] == '1'
never evaluated: v[0] == '1'
0
1279 && v[1] >= '0' && v[1] <= '9'
never evaluated: v[1] >= '0'
never evaluated: v[1] <= '9'
0
1280 && v[2] >= '0' && v[2] <= '9')
never evaluated: v[2] >= '0'
never evaluated: v[2] <= '9'
0
1281 continue;
never executed: continue;
0
1282 }
never executed: }
0
1283 -
1284 it = cacheHeaders.findRawHeader(header); -
1285 if (it != cacheHeaders.rawHeaders.constEnd()) {
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:278
17-278
1286 -
1287 if (header == "content-encoding"
partially evaluated: header == "content-encoding"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1288 || header == "content-range"
partially evaluated: header == "content-range"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1289 || header == "content-type")
partially evaluated: header == "content-type"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1290 continue;
never executed: continue;
0
1291 -
1292 -
1293 -
1294 if (header == "content-length")
partially evaluated: header == "content-length"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
1295 continue;
never executed: continue;
0
1296 }
executed: }
Execution Count:17
17
1297 cacheHeaders.setRawHeader(originalHeader, q->rawHeader(header)); -
1298 }
executed: }
Execution Count:295
295
1299 metaData.setRawHeaders(cacheHeaders.rawHeaders); -
1300 -
1301 bool checkExpired = true; -
1302 -
1303 QHash<QByteArray, QByteArray> cacheControl; -
1304 it = cacheHeaders.findRawHeader("Cache-Control"); -
1305 if (it != cacheHeaders.rawHeaders.constEnd()) {
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:45
28-45
1306 cacheControl = parseHttpOptionHeader(it->second); -
1307 QByteArray maxAge = cacheControl.value("max-age"); -
1308 if (!maxAge.isEmpty()) {
evaluated: !maxAge.isEmpty()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:7
7-21
1309 checkExpired = false; -
1310 QDateTime dt = QDateTime::currentDateTime(); -
1311 dt = dt.addSecs(maxAge.toInt()); -
1312 metaData.setExpirationDate(dt); -
1313 }
executed: }
Execution Count:21
21
1314 }
executed: }
Execution Count:28
28
1315 if (checkExpired) {
evaluated: checkExpired
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:21
21-52
1316 it = cacheHeaders.findRawHeader("expires"); -
1317 if (it != cacheHeaders.rawHeaders.constEnd()) {
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:35
17-35
1318 QDateTime expiredDateTime = QNetworkHeadersPrivate::fromHttpDate(it->second); -
1319 metaData.setExpirationDate(expiredDateTime); -
1320 }
executed: }
Execution Count:17
17
1321 }
executed: }
Execution Count:52
52
1322 -
1323 it = cacheHeaders.findRawHeader("last-modified"); -
1324 if (it != cacheHeaders.rawHeaders.constEnd())
evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:40
33-40
1325 metaData.setLastModified(QNetworkHeadersPrivate::fromHttpDate(it->second));
executed: metaData.setLastModified(QNetworkHeadersPrivate::fromHttpDate(it->second));
Execution Count:33
33
1326 -
1327 bool canDiskCache; -
1328 -
1329 -
1330 if (httpRequest.operation() == QHttpNetworkRequest::Get) {
partially evaluated: httpRequest.operation() == QHttpNetworkRequest::Get
TRUEFALSE
yes
Evaluation Count:73
no
Evaluation Count:0
0-73
1331 -
1332 canDiskCache = true; -
1333 -
1334 -
1335 -
1336 it = cacheHeaders.findRawHeader("pragma"); -
1337 if (it != cacheHeaders.rawHeaders.constEnd()
partially evaluated: it != cacheHeaders.rawHeaders.constEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:73
0-73
1338 && it->second == "no-cache")
never evaluated: it->second == "no-cache"
0
1339 canDiskCache = false;
never executed: canDiskCache = false;
0
1340 -
1341 -
1342 if (cacheControl.contains("no-cache"))
evaluated: cacheControl.contains("no-cache")
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:66
7-66
1343 canDiskCache = false;
executed: canDiskCache = false;
Execution Count:7
7
1344 else if (cacheControl.contains("no-store"))
partially evaluated: cacheControl.contains("no-store")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-66
1345 canDiskCache = false;
never executed: canDiskCache = false;
0
1346 -
1347 -
1348 } else if (httpRequest.operation() == QHttpNetworkRequest::Post) {
never evaluated: httpRequest.operation() == QHttpNetworkRequest::Post
0
1349 -
1350 canDiskCache = false; -
1351 -
1352 -
1353 if (cacheControl.contains("max-age"))
never evaluated: cacheControl.contains("max-age")
0
1354 canDiskCache = true;
never executed: canDiskCache = true;
0
1355 -
1356 -
1357 } else {
never executed: }
0
1358 canDiskCache = false; -
1359 }
never executed: }
0
1360 -
1361 metaData.setSaveToDisk(canDiskCache); -
1362 QNetworkCacheMetaData::AttributesMap attributes; -
1363 if (statusCode != 304) {
evaluated: statusCode != 304
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:11
11-62
1364 -
1365 attributes.insert(QNetworkRequest::HttpStatusCodeAttribute, statusCode); -
1366 attributes.insert(QNetworkRequest::HttpReasonPhraseAttribute, reasonPhrase); -
1367 } else {
executed: }
Execution Count:62
62
1368 -
1369 attributes = oldMetaData.attributes(); -
1370 }
executed: }
Execution Count:11
11
1371 metaData.setAttributes(attributes); -
1372 return metaData;
executed: return metaData;
Execution Count:73
73
1373} -
1374 -
1375bool QNetworkReplyHttpImplPrivate::canResume() const -
1376{ -
1377 const QNetworkReplyHttpImpl * const q = q_func(); -
1378 -
1379 -
1380 if (operation != QNetworkAccessManager::GetOperation)
never evaluated: operation != QNetworkAccessManager::GetOperation
0
1381 return false;
never executed: return false;
0
1382 -
1383 -
1384 QByteArray acceptRangesheaderName("Accept-Ranges"); -
1385 if (!q->hasRawHeader(acceptRangesheaderName) || q->rawHeader(acceptRangesheaderName) == "none")
never evaluated: !q->hasRawHeader(acceptRangesheaderName)
never evaluated: q->rawHeader(acceptRangesheaderName) == "none"
0
1386 return false;
never executed: return false;
0
1387 -
1388 -
1389 if (request.hasRawHeader("Range")) {
never evaluated: request.hasRawHeader("Range")
0
1390 QByteArray range = request.rawHeader("Range"); -
1391 if (!range.startsWith("bytes="))
never evaluated: !range.startsWith("bytes=")
0
1392 return false;
never executed: return false;
0
1393 }
never executed: }
0
1394 -
1395 -
1396 -
1397 if (downloadZerocopyBuffer)
never evaluated: downloadZerocopyBuffer
0
1398 return false;
never executed: return false;
0
1399 -
1400 return true;
never executed: return true;
0
1401} -
1402 -
1403void QNetworkReplyHttpImplPrivate::setResumeOffset(quint64 offset) -
1404{ -
1405 resumeOffset = offset; -
1406}
never executed: }
0
1407 -
1408 -
1409 -
1410 -
1411 -
1412 -
1413bool QNetworkReplyHttpImplPrivate::start() -
1414{ -
1415 -
1416 QSharedPointer<QNetworkSession> networkSession(managerPrivate->getNetworkSession()); -
1417 if (!networkSession) {
evaluated: !networkSession
TRUEFALSE
yes
Evaluation Count:709
yes
Evaluation Count:7
7-709
1418 -
1419 postRequest(); -
1420 return true;
executed: return true;
Execution Count:709
709
1421 -
1422 } -
1423 -
1424 -
1425 const QString host = url.host(); -
1426 if (host == QLatin1String("localhost") ||
partially evaluated: host == QLatin1String("localhost")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1427 QHostAddress(host).isLoopback()) {
partially evaluated: QHostAddress(host).isLoopback()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1428 -
1429 postRequest(); -
1430 return true;
never executed: return true;
0
1431 } -
1432 -
1433 if (networkSession->isOpen() &&
evaluated: networkSession->isOpen()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
1434 networkSession->state() == QNetworkSession::Connected) {
partially evaluated: networkSession->state() == QNetworkSession::Connected
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
1435 QNetworkReplyHttpImpl * const q = q_func(); -
1436 QObject::connect(networkSession.data(), "2""usagePoliciesChanged(QNetworkSession::UsagePolicies)", -
1437 q, "1""_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies)"); -
1438 postRequest(); -
1439 return true;
executed: return true;
Execution Count:3
3
1440 } -
1441 -
1442 return false;
executed: return false;
Execution Count:4
4
1443 -
1444} -
1445 -
1446void QNetworkReplyHttpImplPrivate::_q_startOperation() -
1447{ -
1448 QNetworkReplyHttpImpl * const q = q_func(); -
1449 -
1450 -
1451 if (state == Working) {
partially evaluated: state == Working
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:716
0-716
1452 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 1554, __PRETTY_FUNCTION__).debug("QNetworkReplyImpl::_q_startOperation was called more than once"); -
1453 return;
never executed: return;
0
1454 } -
1455 state = Working; -
1456 -
1457 -
1458 -
1459 QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession()); -
1460 QVariant isBackground = request.attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false)); -
1461 if (isBackground.toBool() && session && session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy)) {
partially evaluated: isBackground.toBool()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:716
never evaluated: session
never evaluated: session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy)
0-716
1462 QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection, -
1463 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::BackgroundRequestNotAllowedError), -
1464 QArgument<QString >("QString", QCoreApplication::translate("QNetworkReply", "Background request not allowed."))); -
1465 QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); -
1466 return;
never executed: return;
0
1467 } -
1468 -
1469 -
1470 if (!start()) {
evaluated: !start()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:712
4-712
1471 -
1472 -
1473 -
1474 -
1475 state = WaitingForSession; -
1476 -
1477 if (session) {
partially evaluated: session
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1478 QObject::connect(session.data(), "2""error(QNetworkSession::SessionError)", -
1479 q, "1""_q_networkSessionFailed()", Qt::QueuedConnection); -
1480 -
1481 if (!session->isOpen()) {
partially evaluated: !session->isOpen()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
1482 session->setSessionProperty(QString::fromUtf8("" "ConnectInBackground" "", sizeof("ConnectInBackground") - 1), isBackground); -
1483 session->open(); -
1484 }
executed: }
Execution Count:4
4
1485 } else {
executed: }
Execution Count:4
4
1486 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 1588, __PRETTY_FUNCTION__).warning("Backend is waiting for QNetworkSession to connect, but there is none!"); -
1487 QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection, -
1488 QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", QNetworkReply::NetworkSessionFailedError), -
1489 QArgument<QString >("QString", QCoreApplication::translate("QNetworkReply", "Network session error."))); -
1490 QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); -
1491 return;
never executed: return;
0
1492 } -
1493 } -
1494 -
1495 if (synchronous) {
evaluated: synchronous
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:640
76-640
1496 state = Finished; -
1497 q_func()->setFinished(true); -
1498 } else {
executed: }
Execution Count:76
76
1499 if (state != Finished) {
partially evaluated: state != Finished
TRUEFALSE
yes
Evaluation Count:640
no
Evaluation Count:0
0-640
1500 -
1501 }
executed: }
Execution Count:640
640
1502 }
executed: }
Execution Count:640
640
1503} -
1504 -
1505void QNetworkReplyHttpImplPrivate::_q_cacheLoadReadyRead() -
1506{ -
1507 QNetworkReplyHttpImpl * const q = q_func(); -
1508 -
1509 if (state != Working)
partially evaluated: state != Working
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1510 return;
never executed: return;
0
1511 if (!cacheLoadDevice || !q->isOpen() || !cacheLoadDevice->bytesAvailable())
partially evaluated: !cacheLoadDevice
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
partially evaluated: !q->isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
partially evaluated: !cacheLoadDevice->bytesAvailable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1512 return;
never executed: return;
0
1513 -
1514 -
1515 -
1516 -
1517 -
1518 -
1519 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); -
1520 -
1521 -
1522 -
1523 -
1524 -
1525 q->readyRead(); -
1526 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:19
6-19
1527 downloadProgressSignalChoke.restart(); -
1528 q->downloadProgress(bytesDownloaded, -
1529 totalSize.isNull() ? static_cast<long long>(-1LL) : totalSize.toLongLong()); -
1530 }
executed: }
Execution Count:6
6
1531 -
1532 -
1533 -
1534 -
1535 while (cacheLoadDevice->bytesAvailable()) {
evaluated: cacheLoadDevice->bytesAvailable()
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:25
25
1536 downloadMultiBuffer.append(cacheLoadDevice->readAll()); -
1537 }
executed: }
Execution Count:25
25
1538 -
1539 if (cacheLoadDevice->isSequential()) {
partially evaluated: cacheLoadDevice->isSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
1540 -
1541 char c; -
1542 qint64 actualCount = cacheLoadDevice->read(&c, 1); -
1543 if (actualCount < 0) {
never evaluated: actualCount < 0
0
1544 cacheLoadDevice->deleteLater(); -
1545 cacheLoadDevice = 0; -
1546 QMetaObject::invokeMethod(q, "_q_finished", Qt::QueuedConnection); -
1547 } else if (actualCount == 1) {
never executed: }
never evaluated: actualCount == 1
0
1548 -
1549 -
1550 cacheLoadDevice->ungetChar(c); -
1551 }
never executed: }
0
1552 } else if ((!cacheLoadDevice->isSequential() && cacheLoadDevice->atEnd())) {
partially evaluated: !cacheLoadDevice->isSequential()
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
partially evaluated: cacheLoadDevice->atEnd()
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
1553 -
1554 cacheLoadDevice->deleteLater(); -
1555 cacheLoadDevice = 0; -
1556 QMetaObject::invokeMethod(q, "_q_finished", Qt::QueuedConnection); -
1557 }
executed: }
Execution Count:25
25
1558 -
1559} -
1560 -
1561 -
1562void QNetworkReplyHttpImplPrivate::_q_bufferOutgoingDataFinished() -
1563{ -
1564 QNetworkReplyHttpImpl * const q = q_func(); -
1565 -
1566 -
1567 -
1568 if (state != Buffering)
partially evaluated: state != Buffering
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
0-60
1569 return;
never executed: return;
0
1570 -
1571 -
1572 QObject::disconnect(outgoingData, "2""readyRead()", q, "1""_q_bufferOutgoingData()"); -
1573 QObject::disconnect(outgoingData, "2""readChannelFinished()", q, "1""_q_bufferOutgoingDataFinished()"); -
1574 -
1575 -
1576 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); -
1577}
executed: }
Execution Count:60
60
1578 -
1579void QNetworkReplyHttpImplPrivate::_q_bufferOutgoingData() -
1580{ -
1581 QNetworkReplyHttpImpl * const q = q_func(); -
1582 -
1583 if (!outgoingDataBuffer) {
evaluated: !outgoingDataBuffer
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:60
60
1584 -
1585 outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer()); -
1586 -
1587 QObject::connect(outgoingData, "2""readyRead()", q, "1""_q_bufferOutgoingData()"); -
1588 QObject::connect(outgoingData, "2""readChannelFinished()", q, "1""_q_bufferOutgoingDataFinished()"); -
1589 }
executed: }
Execution Count:60
60
1590 -
1591 qint64 bytesBuffered = 0; -
1592 qint64 bytesToBuffer = 0; -
1593 -
1594 -
1595 for(;;) { -
1596 bytesToBuffer = outgoingData->bytesAvailable(); -
1597 -
1598 if (bytesToBuffer <= 0)
evaluated: bytesToBuffer <= 0
TRUEFALSE
yes
Evaluation Count:140
yes
Evaluation Count:70
70-140
1599 bytesToBuffer = 2*1024;
executed: bytesToBuffer = 2*1024;
Execution Count:140
140
1600 -
1601 char *dst = outgoingDataBuffer->reserve(bytesToBuffer); -
1602 bytesBuffered = outgoingData->read(dst, bytesToBuffer); -
1603 -
1604 if (bytesBuffered == -1) {
evaluated: bytesBuffered == -1
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:150
60-150
1605 -
1606 outgoingDataBuffer->chop(bytesToBuffer); -
1607 -
1608 _q_bufferOutgoingDataFinished(); -
1609 break;
executed: break;
Execution Count:60
60
1610 } else if (bytesBuffered == 0) {
evaluated: bytesBuffered == 0
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:90
60-90
1611 -
1612 outgoingDataBuffer->chop(bytesToBuffer); -
1613 -
1614 break;
executed: break;
Execution Count:60
60
1615 } else { -
1616 -
1617 outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered); -
1618 }
executed: }
Execution Count:90
90
1619 } -
1620}
executed: }
Execution Count:120
120
1621 -
1622 -
1623void QNetworkReplyHttpImplPrivate::_q_networkSessionConnected() -
1624{ -
1625 QNetworkReplyHttpImpl * const q = q_func(); -
1626 -
1627 if (!manager)
partially evaluated: !manager
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1628 return;
never executed: return;
0
1629 -
1630 QSharedPointer<QNetworkSession> session = managerPrivate->getNetworkSession(); -
1631 if (!session)
partially evaluated: !session
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1632 return;
never executed: return;
0
1633 -
1634 if (session->state() != QNetworkSession::Connected)
partially evaluated: session->state() != QNetworkSession::Connected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1635 return;
never executed: return;
0
1636 -
1637 switch (state) { -
1638 case QNetworkReplyImplPrivate::Buffering: -
1639 case QNetworkReplyImplPrivate::Working: -
1640 case QNetworkReplyImplPrivate::Reconnecting: -
1641 -
1642 migrateBackend(); -
1643 break;
never executed: break;
0
1644 case QNetworkReplyImplPrivate::WaitingForSession: -
1645 -
1646 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); -
1647 break;
executed: break;
Execution Count:3
3
1648 default: -
1649 ; -
1650 }
never executed: }
0
1651}
executed: }
Execution Count:3
3
1652 -
1653void QNetworkReplyHttpImplPrivate::_q_networkSessionFailed() -
1654{ -
1655 -
1656 if (state == WaitingForSession || state == Working) {
partially evaluated: state == WaitingForSession
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
never evaluated: state == Working
0-1
1657 state = Working; -
1658 QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession()); -
1659 QString errorStr; -
1660 if (session)
partially evaluated: session
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1661 errorStr = session->errorString();
executed: errorStr = session->errorString();
Execution Count:1
1
1662 else -
1663 errorStr = QCoreApplication::translate("QNetworkReply", "Network session error.");
never executed: errorStr = QCoreApplication::translate("QNetworkReply", "Network session error.");
0
1664 error(QNetworkReplyImpl::NetworkSessionFailedError, errorStr); -
1665 finished(); -
1666 }
executed: }
Execution Count:1
1
1667}
executed: }
Execution Count:1
1
1668 -
1669void QNetworkReplyHttpImplPrivate::_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies newPolicies) -
1670{ -
1671 if (request.attribute(QNetworkRequest::BackgroundRequestAttribute).toBool()) {
never evaluated: request.attribute(QNetworkRequest::BackgroundRequestAttribute).toBool()
0
1672 if (newPolicies & QNetworkSession::NoBackgroundTrafficPolicy) {
never evaluated: newPolicies & QNetworkSession::NoBackgroundTrafficPolicy
0
1673 -
1674 if (state == WaitingForSession || state == Working) {
never evaluated: state == WaitingForSession
never evaluated: state == Working
0
1675 state = Working; -
1676 error(QNetworkReply::BackgroundRequestNotAllowedError, -
1677 QCoreApplication::translate("QNetworkReply", "Background request not allowed.")); -
1678 finished(); -
1679 }
never executed: }
0
1680 -
1681 }
never executed: }
0
1682 }
never executed: }
0
1683 -
1684}
never executed: }
0
1685 -
1686 -
1687 -
1688 -
1689 -
1690void QNetworkReplyHttpImplPrivate::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal) -
1691{ -
1692 QNetworkReplyHttpImpl * const q = q_func(); -
1693 if (isFinished)
partially evaluated: isFinished
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1875
0-1875
1694 return;
never executed: return;
0
1695 -
1696 -
1697 if (uploadProgressSignalChoke.isValid()) {
evaluated: uploadProgressSignalChoke.isValid()
TRUEFALSE
yes
Evaluation Count:1757
yes
Evaluation Count:118
118-1757
1698 if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) {
evaluated: bytesSent != bytesTotal
TRUEFALSE
yes
Evaluation Count:1689
yes
Evaluation Count:68
evaluated: uploadProgressSignalChoke.elapsed() < progressSignalInterval
TRUEFALSE
yes
Evaluation Count:1681
yes
Evaluation Count:8
8-1689
1699 return;
executed: return;
Execution Count:1681
1681
1700 } -
1701 uploadProgressSignalChoke.restart(); -
1702 } else {
executed: }
Execution Count:76
76
1703 uploadProgressSignalChoke.start(); -
1704 }
executed: }
Execution Count:118
118
1705 -
1706 q->uploadProgress(bytesSent, bytesTotal); -
1707}
executed: }
Execution Count:194
194
1708 -
1709QNonContiguousByteDevice* QNetworkReplyHttpImplPrivate::createUploadByteDevice() -
1710{ -
1711 QNetworkReplyHttpImpl * const q = q_func(); -
1712 -
1713 if (outgoingDataBuffer)
evaluated: outgoingDataBuffer
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:82
82-101
1714 uploadByteDevice = QSharedPointer<QNonContiguousByteDevice>(QNonContiguousByteDeviceFactory::create(outgoingDataBuffer));
executed: uploadByteDevice = QSharedPointer<QNonContiguousByteDevice>(QNonContiguousByteDeviceFactory::create(outgoingDataBuffer));
Execution Count:101
101
1715 else if (outgoingData) {
evaluated: outgoingData
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:4
4-78
1716 uploadByteDevice = QSharedPointer<QNonContiguousByteDevice>(QNonContiguousByteDeviceFactory::create(outgoingData)); -
1717 } else {
executed: }
Execution Count:78
78
1718 return 0;
executed: return 0;
Execution Count:4
4
1719 } -
1720 -
1721 bool bufferDisallowed = -
1722 request.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute, -
1723 QVariant(false)) == QVariant(true); -
1724 if (bufferDisallowed)
evaluated: bufferDisallowed
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:178
1-178
1725 uploadByteDevice->disableReset();
executed: uploadByteDevice->disableReset();
Execution Count:1
1
1726 -
1727 -
1728 if (!synchronous)
evaluated: !synchronous
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:41
41-138
1729 QObject::connect(uploadByteDevice.data(), "2""readProgress(qint64,qint64)", 138
1730 q, "1""emitReplyUploadProgress(qint64,qint64)");
executed: QObject::connect(uploadByteDevice.data(), "2""readProgress(qint64,qint64)", q, "1""emitReplyUploadProgress(qint64,qint64)");
Execution Count:138
138
1731 -
1732 return uploadByteDevice.data();
executed: return uploadByteDevice.data();
Execution Count:179
179
1733} -
1734 -
1735void QNetworkReplyHttpImplPrivate::_q_finished() -
1736{ -
1737 -
1738 finished(); -
1739}
executed: }
Execution Count:28
28
1740 -
1741void QNetworkReplyHttpImplPrivate::finished() -
1742{ -
1743 QNetworkReplyHttpImpl * const q = q_func(); -
1744 -
1745 if (state == Finished || state == Aborted || state == WaitingForSession)
partially evaluated: state == Finished
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:697
partially evaluated: state == Aborted
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:697
partially evaluated: state == WaitingForSession
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:697
0-697
1746 return;
never executed: return;
0
1747 -
1748 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); -
1749 if (preMigrationDownloaded != static_cast<long long>(-1LL))
partially evaluated: preMigrationDownloaded != static_cast<long long>(-1LL)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:697
0-697
1750 totalSize = totalSize.toLongLong() + preMigrationDownloaded;
never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded;
0
1751 -
1752 if (manager) {
partially evaluated: manager
TRUEFALSE
yes
Evaluation Count:697
no
Evaluation Count:0
0-697
1753 -
1754 QSharedPointer<QNetworkSession> session = managerPrivate->getNetworkSession(); -
1755 if (session && session->state() == QNetworkSession::Roaming &&
evaluated: session
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:693
partially evaluated: session->state() == QNetworkSession::Roaming
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-693
1756 state == Working && errorCode != QNetworkReply::OperationCanceledError) {
never evaluated: state == Working
never evaluated: errorCode != QNetworkReply::OperationCanceledError
0
1757 -
1758 if (!totalSize.isNull()) {
never evaluated: !totalSize.isNull()
0
1759 if (bytesDownloaded != totalSize) {
never evaluated: bytesDownloaded != totalSize
0
1760 if (migrateBackend()) {
never evaluated: migrateBackend()
0
1761 -
1762 if (state == Reconnecting || state == WaitingForSession) {
never evaluated: state == Reconnecting
never evaluated: state == WaitingForSession
0
1763 return;
never executed: return;
0
1764 } -
1765 } else {
never executed: }
0
1766 error(QNetworkReply::TemporaryNetworkFailureError, -
1767 QNetworkReply::tr("Temporary network failure.")); -
1768 }
never executed: }
0
1769 } -
1770 }
never executed: }
0
1771 }
never executed: }
0
1772 -
1773 }
executed: }
Execution Count:697
697
1774 -
1775 state = Finished; -
1776 q->setFinished(true); -
1777 -
1778 if (totalSize.isNull() || totalSize == -1) {
evaluated: totalSize.isNull()
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:491
partially evaluated: totalSize == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:491
0-491
1779 q->downloadProgress(bytesDownloaded, bytesDownloaded); -
1780 } else {
executed: }
Execution Count:206
206
1781 q->downloadProgress(bytesDownloaded, totalSize.toLongLong()); -
1782 }
executed: }
Execution Count:491
491
1783 -
1784 if (bytesUploaded == -1 && (outgoingData || outgoingDataBuffer))
partially evaluated: bytesUploaded == -1
TRUEFALSE
yes
Evaluation Count:697
no
Evaluation Count:0
evaluated: outgoingData
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:519
partially evaluated: outgoingDataBuffer
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:519
0-697
1785 q->uploadProgress(0, 0);
executed: q->uploadProgress(0, 0);
Execution Count:178
178
1786 -
1787 -
1788 if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
evaluated: totalSize.isNull()
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:491
partially evaluated: totalSize == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:491
evaluated: bytesDownloaded == totalSize
TRUEFALSE
yes
Evaluation Count:450
yes
Evaluation Count:41
0-491
1789 completeCacheSave();
executed: completeCacheSave();
Execution Count:656
656
1790 -
1791 q->readChannelFinished(); -
1792 q->finished(); -
1793}
executed: }
Execution Count:697
697
1794 -
1795void QNetworkReplyHttpImplPrivate::_q_error(QNetworkReplyImpl::NetworkError code, const QString &errorMessage) -
1796{ -
1797 this->error(code, errorMessage); -
1798}
executed: }
Execution Count:3
3
1799 -
1800 -
1801void QNetworkReplyHttpImplPrivate::error(QNetworkReplyImpl::NetworkError code, const QString &errorMessage) -
1802{ -
1803 QNetworkReplyHttpImpl * const q = q_func(); -
1804 -
1805 if (errorCode != QNetworkReply::NoError) {
partially evaluated: errorCode != QNetworkReply::NoError
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:94
0-94
1806 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 1916, __PRETTY_FUNCTION__).warning("QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once."); -
1807 return;
never executed: return;
0
1808 } -
1809 -
1810 errorCode = code; -
1811 q->setErrorString(errorMessage); -
1812 -
1813 -
1814 -
1815 -
1816 q->error(code); -
1817}
executed: }
Execution Count:94
94
1818 -
1819void QNetworkReplyHttpImplPrivate::metaDataChanged() -
1820{ -
1821 -
1822 -
1823 QNetworkReplyHttpImpl * const q = q_func(); -
1824 -
1825 -
1826 if (cookedHeaders.contains(QNetworkRequest::SetCookieHeader) && manager
evaluated: cookedHeaders.contains(QNetworkRequest::SetCookieHeader)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:616
partially evaluated: manager
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-616
1827 && (static_cast<QNetworkRequest::LoadControl> 0-12
1828 (request.attribute(QNetworkRequest::CookieSaveControlAttribute, 0-12
1829 QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)) {
partially evaluated: (static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1830 QList<QNetworkCookie> cookies = -
1831 qvariant_cast<QList<QNetworkCookie> >(cookedHeaders.value(QNetworkRequest::SetCookieHeader)); -
1832 QNetworkCookieJar *jar = manager->cookieJar(); -
1833 if (jar)
partially evaluated: jar
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1834 jar->setCookiesFromUrl(cookies, url);
executed: jar->setCookiesFromUrl(cookies, url);
Execution Count:12
12
1835 }
executed: }
Execution Count:12
12
1836 q->metaDataChanged(); -
1837}
executed: }
Execution Count:628
628
1838 -
1839 -
1840 -
1841 -
1842 -
1843bool QNetworkReplyHttpImplPrivate::migrateBackend() -
1844{ -
1845 QNetworkReplyHttpImpl * const q = q_func(); -
1846 -
1847 -
1848 if (state == Finished || state == Aborted)
never evaluated: state == Finished
never evaluated: state == Aborted
0
1849 return true;
never executed: return true;
0
1850 -
1851 -
1852 if (!canResume())
never evaluated: !canResume()
0
1853 return false;
never executed: return false;
0
1854 -
1855 -
1856 if (outgoingData)
never evaluated: outgoingData
0
1857 return false;
never executed: return false;
0
1858 -
1859 -
1860 if (cacheLoadDevice)
never evaluated: cacheLoadDevice
0
1861 return true;
never executed: return true;
0
1862 -
1863 state = Reconnecting; -
1864 -
1865 cookedHeaders.clear(); -
1866 rawHeaders.clear(); -
1867 -
1868 preMigrationDownloaded = bytesDownloaded; -
1869 -
1870 setResumeOffset(bytesDownloaded); -
1871 -
1872 q->abortHttpRequest(); -
1873 -
1874 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); -
1875 -
1876 return true;
never executed: return true;
0
1877} -
1878 -
1879 -
1880void QNetworkReplyHttpImplPrivate::createCache() -
1881{ -
1882 -
1883 if (!managerPrivate->networkCache
evaluated: !managerPrivate->networkCache
TRUEFALSE
yes
Evaluation Count:552
yes
Evaluation Count:76
76-552
1884 || !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool())
evaluated: !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:66
10-66
1885 return;
executed: return;
Execution Count:562
562
1886 cacheEnabled = true; -
1887}
executed: }
Execution Count:66
66
1888 -
1889bool QNetworkReplyHttpImplPrivate::isCachingEnabled() const -
1890{ -
1891 return (cacheEnabled && managerPrivate->networkCache != 0);
executed: return (cacheEnabled && managerPrivate->networkCache != 0);
Execution Count:628
628
1892} -
1893 -
1894void QNetworkReplyHttpImplPrivate::setCachingEnabled(bool enable) -
1895{ -
1896 if (!enable && !cacheEnabled)
evaluated: !enable
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:628
partially evaluated: !cacheEnabled
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-628
1897 return;
executed: return;
Execution Count:25
25
1898 if (enable && cacheEnabled)
partially evaluated: enable
TRUEFALSE
yes
Evaluation Count:628
no
Evaluation Count:0
partially evaluated: cacheEnabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:628
0-628
1899 return;
never executed: return;
0
1900 -
1901 if (enable) {
partially evaluated: enable
TRUEFALSE
yes
Evaluation Count:628
no
Evaluation Count:0
0-628
1902 if (bytesDownloaded) {
partially evaluated: bytesDownloaded
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:628
0-628
1903 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 2013, __PRETTY_FUNCTION__).debug() << "setCachingEnabled: " << bytesDownloaded << " bytesDownloaded"; -
1904 -
1905 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 2015, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written"); -
1906 return;
never executed: return;
0
1907 } -
1908 -
1909 createCache(); -
1910 } else {
executed: }
Execution Count:628
628
1911 -
1912 -
1913 QMessageLogger("access/qnetworkreplyhttpimpl.cpp", 2023, __PRETTY_FUNCTION__).debug("QNetworkReplyImpl: setCachingEnabled(true) called after setCachingEnabled(false)"); -
1914 managerPrivate->networkCache->remove(url); -
1915 cacheSaveDevice = 0; -
1916 cacheEnabled = false; -
1917 }
never executed: }
0
1918} -
1919 -
1920bool QNetworkReplyHttpImplPrivate::isCachingAllowed() const -
1921{ -
1922 return operation == QNetworkAccessManager::GetOperation || operation == QNetworkAccessManager::HeadOperation;
executed: return operation == QNetworkAccessManager::GetOperation || operation == QNetworkAccessManager::HeadOperation;
Execution Count:65
65
1923} -
1924 -
1925void QNetworkReplyHttpImplPrivate::completeCacheSave() -
1926{ -
1927 if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) {
evaluated: cacheEnabled
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:599
partially evaluated: errorCode != QNetworkReplyImpl::NoError
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:57
0-599
1928 managerPrivate->networkCache->remove(url); -
1929 } else if (cacheEnabled && cacheSaveDevice) {
never executed: }
evaluated: cacheEnabled
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:599
evaluated: cacheSaveDevice
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:2
0-599
1930 managerPrivate->networkCache->insert(cacheSaveDevice); -
1931 }
executed: }
Execution Count:55
55
1932 cacheSaveDevice = 0; -
1933 cacheEnabled = false; -
1934}
executed: }
Execution Count:656
656
1935 -
1936 -
1937 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial