access/qnetworkaccesscachebackend.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4QNetworkAccessCacheBackend::QNetworkAccessCacheBackend() -
5 : QNetworkAccessBackend() -
6 , device(0) -
7{ -
8}
executed: }
Execution Count:13
13
9 -
10QNetworkAccessCacheBackend::~QNetworkAccessCacheBackend() -
11{ -
12} -
13 -
14void QNetworkAccessCacheBackend::open() -
15{ -
16 if (operation() != QNetworkAccessManager::GetOperation || !sendCacheContents()) {
partially evaluated: operation() != QNetworkAccessManager::GetOperation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: !sendCacheContents()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:9
0-13
17 QString msg = QCoreApplication::translate("QNetworkAccessCacheBackend", "Error opening %1") -
18 .arg(this->url().toString()); -
19 error(QNetworkReply::ContentNotFoundError, msg); -
20 } else {
executed: }
Execution Count:4
4
21 setAttribute(QNetworkRequest::SourceIsFromCacheAttribute, true); -
22 }
executed: }
Execution Count:9
9
23 finished(); -
24}
executed: }
Execution Count:13
13
25 -
26bool QNetworkAccessCacheBackend::sendCacheContents() -
27{ -
28 setCachingEnabled(false); -
29 QAbstractNetworkCache *nc = networkCache(); -
30 if (!nc)
partially evaluated: !nc
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
31 return false;
never executed: return false;
0
32 -
33 QNetworkCacheMetaData item = nc->metaData(url()); -
34 if (!item.isValid())
evaluated: !item.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12
1-12
35 return false;
executed: return false;
Execution Count:1
1
36 -
37 QNetworkCacheMetaData::AttributesMap attributes = item.attributes(); -
38 setAttribute(QNetworkRequest::HttpStatusCodeAttribute, attributes.value(QNetworkRequest::HttpStatusCodeAttribute)); -
39 setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); -
40 -
41 -
42 QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); -
43 QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), -
44 end = rawHeaders.constEnd(); -
45 for ( ; it != end; ++it) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:9
9-39
46 if (it->first.toLower() == "cache-control" &&
evaluated: it->first.toLower() == "cache-control"
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:34
5-34
47 it->second.toLower().contains("must-revalidate")) {
evaluated: it->second.toLower().contains("must-revalidate")
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
48 return false;
executed: return false;
Execution Count:3
3
49 } -
50 setRawHeader(it->first, it->second); -
51 }
executed: }
Execution Count:36
36
52 -
53 -
54 QVariant redirectionTarget = attributes.value(QNetworkRequest::RedirectionTargetAttribute); -
55 if (redirectionTarget.isValid()) {
partially evaluated: redirectionTarget.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
56 setAttribute(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); -
57 redirectionRequested(redirectionTarget.toUrl()); -
58 }
never executed: }
0
59 -
60 -
61 metaDataChanged(); -
62 -
63 if (operation() == QNetworkAccessManager::GetOperation) {
partially evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
64 QIODevice *contents = nc->data(url()); -
65 if (!contents)
partially evaluated: !contents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
66 return false;
never executed: return false;
0
67 contents->setParent(this); -
68 writeDownstreamData(contents); -
69 }
executed: }
Execution Count:9
9
70 -
71 -
72 -
73 -
74 return true;
executed: return true;
Execution Count:9
9
75} -
76 -
77void QNetworkAccessCacheBackend::closeDownstreamChannel() -
78{ -
79 if (operation() == QNetworkAccessManager::GetOperation) {
never evaluated: operation() == QNetworkAccessManager::GetOperation
0
80 device->close(); -
81 delete device; -
82 device = 0; -
83 }
never executed: }
0
84}
never executed: }
0
85 -
86void QNetworkAccessCacheBackend::closeUpstreamChannel() -
87{ -
88 qt_noop(); -
89}
never executed: }
0
90 -
91void QNetworkAccessCacheBackend::upstreamReadyRead() -
92{ -
93 qt_noop(); -
94}
never executed: }
0
95 -
96void QNetworkAccessCacheBackend::downstreamReadyWrite() -
97{ -
98 qt_noop(); -
99}
never executed: }
0
100 -
101 -
102 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial