access/qnetworkrequest.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate -
9{ -
10public: -
11 inline QNetworkRequestPrivate() -
12 : priority(QNetworkRequest::NormalPriority) -
13 -
14 , sslConfiguration(0) -
15 -
16 { qRegisterMetaType<QNetworkRequest>(); }
executed: }
Execution Count:1694
1694
17 ~QNetworkRequestPrivate() -
18 { -
19 -
20 delete sslConfiguration; -
21 -
22 }
executed: }
Execution Count:1911
1911
23 -
24 -
25 QNetworkRequestPrivate(const QNetworkRequestPrivate &other) -
26 : QSharedData(other), QNetworkHeadersPrivate(other) -
27 { -
28 url = other.url; -
29 priority = other.priority; -
30 -
31 -
32 sslConfiguration = 0; -
33 if (other.sslConfiguration)
evaluated: other.sslConfiguration
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:122
95-122
34 sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
executed: sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
Execution Count:95
95
35 -
36 }
executed: }
Execution Count:217
217
37 -
38 inline bool operator==(const QNetworkRequestPrivate &other) const -
39 { -
40 return url == other.url && 0
41 priority == other.priority && 0
42 rawHeaders == other.rawHeaders && 0
43 attributes == other.attributes;
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes;
0
44 -
45 } -
46 -
47 QUrl url; -
48 QNetworkRequest::Priority priority; -
49 -
50 mutable QSslConfiguration *sslConfiguration; -
51 -
52}; -
53 -
54 -
55 -
56 -
57 -
58 -
59 -
60QNetworkRequest::QNetworkRequest(const QUrl &url) -
61 : d(new QNetworkRequestPrivate) -
62{ -
63 d->url = url; -
64}
executed: }
Execution Count:1694
1694
65 -
66 -
67 -
68 -
69QNetworkRequest::QNetworkRequest(const QNetworkRequest &other) -
70 : d(other.d) -
71{ -
72}
executed: }
Execution Count:929
929
73 -
74 -
75 -
76 -
77QNetworkRequest::~QNetworkRequest() -
78{ -
79 -
80 d = 0; -
81}
executed: }
Execution Count:2623
2623
82 -
83 -
84 -
85 -
86 -
87 -
88 -
89bool QNetworkRequest::operator==(const QNetworkRequest &other) const -
90{ -
91 return d == other.d || *d == *other.d;
executed: return d == other.d || *d == *other.d;
Execution Count:1
1
92} -
93QNetworkRequest &QNetworkRequest::operator=(const QNetworkRequest &other) -
94{ -
95 d = other.d; -
96 return *this;
executed: return *this;
Execution Count:874
874
97} -
98QUrl QNetworkRequest::url() const -
99{ -
100 return d->url;
executed: return d->url;
Execution Count:5035
5035
101} -
102 -
103 -
104 -
105 -
106 -
107 -
108void QNetworkRequest::setUrl(const QUrl &url) -
109{ -
110 d->url = url; -
111}
executed: }
Execution Count:24
24
112QVariant QNetworkRequest::header(KnownHeaders header) const -
113{ -
114 return d->cookedHeaders.value(header);
executed: return d->cookedHeaders.value(header);
Execution Count:889
889
115} -
116void QNetworkRequest::setHeader(KnownHeaders header, const QVariant &value) -
117{ -
118 d->setCookedHeader(header, value); -
119}
executed: }
Execution Count:182
182
120 -
121 -
122 -
123 -
124 -
125 -
126 -
127bool QNetworkRequest::hasRawHeader(const QByteArray &headerName) const -
128{ -
129 return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
executed: return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
Execution Count:605
605
130} -
131QByteArray QNetworkRequest::rawHeader(const QByteArray &headerName) const -
132{ -
133 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it = -
134 d->findRawHeader(headerName); -
135 if (it != d->rawHeaders.constEnd())
evaluated: it != d->rawHeaders.constEnd()
TRUEFALSE
yes
Evaluation Count:352
yes
Evaluation Count:4
4-352
136 return it->second;
executed: return it->second;
Execution Count:352
352
137 return QByteArray();
executed: return QByteArray();
Execution Count:4
4
138} -
139 -
140 -
141 -
142 -
143 -
144 -
145 -
146QList<QByteArray> QNetworkRequest::rawHeaderList() const -
147{ -
148 return d->rawHeadersKeys();
executed: return d->rawHeadersKeys();
Execution Count:712
712
149} -
150void QNetworkRequest::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue) -
151{ -
152 d->setRawHeader(headerName, headerValue); -
153}
executed: }
Execution Count:197
197
154QVariant QNetworkRequest::attribute(Attribute code, const QVariant &defaultValue) const -
155{ -
156 return d->attributes.value(code, defaultValue);
executed: return d->attributes.value(code, defaultValue);
Execution Count:6336
6336
157} -
158void QNetworkRequest::setAttribute(Attribute code, const QVariant &value) -
159{ -
160 if (value.isValid())
partially evaluated: value.isValid()
TRUEFALSE
yes
Evaluation Count:195
no
Evaluation Count:0
0-195
161 d->attributes.insert(code, value);
executed: d->attributes.insert(code, value);
Execution Count:195
195
162 else -
163 d->attributes.remove(code);
never executed: d->attributes.remove(code);
0
164} -
165QSslConfiguration QNetworkRequest::sslConfiguration() const -
166{ -
167 if (!d->sslConfiguration)
evaluated: !d->sslConfiguration
TRUEFALSE
yes
Evaluation Count:645
yes
Evaluation Count:244
244-645
168 d->sslConfiguration = new QSslConfiguration(QSslConfiguration::defaultConfiguration());
executed: d->sslConfiguration = new QSslConfiguration(QSslConfiguration::defaultConfiguration());
Execution Count:645
645
169 return *d->sslConfiguration;
executed: return *d->sslConfiguration;
Execution Count:889
889
170} -
171void QNetworkRequest::setSslConfiguration(const QSslConfiguration &config) -
172{ -
173 if (!d->sslConfiguration)
partially evaluated: !d->sslConfiguration
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
0-44
174 d->sslConfiguration = new QSslConfiguration(config);
executed: d->sslConfiguration = new QSslConfiguration(config);
Execution Count:44
44
175 else -
176 *d->sslConfiguration = config;
never executed: *d->sslConfiguration = config;
0
177} -
178void QNetworkRequest::setOriginatingObject(QObject *object) -
179{ -
180 d->originatingObject = object; -
181}
executed: }
Execution Count:1
1
182QObject *QNetworkRequest::originatingObject() const -
183{ -
184 return d->originatingObject.data();
executed: return d->originatingObject.data();
Execution Count:3
3
185} -
186QNetworkRequest::Priority QNetworkRequest::priority() const -
187{ -
188 return d->priority;
executed: return d->priority;
Execution Count:709
709
189} -
190void QNetworkRequest::setPriority(Priority priority) -
191{ -
192 d->priority = priority; -
193}
never executed: }
0
194 -
195static QByteArray headerName(QNetworkRequest::KnownHeaders header) -
196{ -
197 switch (header) { -
198 case QNetworkRequest::ContentTypeHeader: -
199 return "Content-Type";
executed: return "Content-Type";
Execution Count:86
86
200 -
201 case QNetworkRequest::ContentLengthHeader: -
202 return "Content-Length";
executed: return "Content-Length";
Execution Count:214
214
203 -
204 case QNetworkRequest::LocationHeader: -
205 return "Location";
executed: return "Location";
Execution Count:3
3
206 -
207 case QNetworkRequest::LastModifiedHeader: -
208 return "Last-Modified";
executed: return "Last-Modified";
Execution Count:50
50
209 -
210 case QNetworkRequest::CookieHeader: -
211 return "Cookie";
executed: return "Cookie";
Execution Count:11
11
212 -
213 case QNetworkRequest::SetCookieHeader: -
214 return "Set-Cookie";
executed: return "Set-Cookie";
Execution Count:3
3
215 -
216 case QNetworkRequest::ContentDispositionHeader: -
217 return "Content-Disposition";
executed: return "Content-Disposition";
Execution Count:30
30
218 -
219 case QNetworkRequest::UserAgentHeader: -
220 return "User-Agent";
executed: return "User-Agent";
Execution Count:1
1
221 -
222 case QNetworkRequest::ServerHeader: -
223 return "Server";
never executed: return "Server";
0
224 -
225 -
226 -
227 } -
228 -
229 return QByteArray();
never executed: return QByteArray();
0
230} -
231 -
232static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value) -
233{ -
234 switch (header) { -
235 case QNetworkRequest::ContentTypeHeader: -
236 case QNetworkRequest::ContentLengthHeader: -
237 case QNetworkRequest::ContentDispositionHeader: -
238 case QNetworkRequest::UserAgentHeader: -
239 case QNetworkRequest::ServerHeader: -
240 return value.toByteArray();
executed: return value.toByteArray();
Execution Count:330
330
241 -
242 case QNetworkRequest::LocationHeader: -
243 switch (value.userType()) { -
244 case QMetaType::QUrl: -
245 return value.toUrl().toEncoded();
executed: return value.toUrl().toEncoded();
Execution Count:1
1
246 -
247 default: -
248 return value.toByteArray();
executed: return value.toByteArray();
Execution Count:2
2
249 } -
250 -
251 case QNetworkRequest::LastModifiedHeader:
code before this statement never executed: case QNetworkRequest::LastModifiedHeader:
0
252 switch (value.userType()) { -
253 case QMetaType::QDate: -
254 case QMetaType::QDateTime: -
255 -
256 return QNetworkHeadersPrivate::toHttpDate(value.toDateTime());
executed: return QNetworkHeadersPrivate::toHttpDate(value.toDateTime());
Execution Count:48
48
257 -
258 default: -
259 return value.toByteArray();
never executed: return value.toByteArray();
0
260 } -
261 -
262 case QNetworkRequest::CookieHeader: { -
263 QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(value); -
264 if (cookies.isEmpty() && value.userType() == qMetaTypeId<QNetworkCookie>())
partially evaluated: cookies.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
never evaluated: value.userType() == qMetaTypeId<QNetworkCookie>()
0-11
265 cookies << qvariant_cast<QNetworkCookie>(value);
never executed: cookies << qvariant_cast<QNetworkCookie>(value);
0
266 -
267 QByteArray result; -
268 bool first = true; -
269 for (QForeachContainer<__typeof__(cookies)> _container_(cookies); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QNetworkCookie &cookie = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
270 if (!first)
evaluated: !first
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:11
3-11
271 result += "; ";
executed: result += "; ";
Execution Count:3
3
272 first = false; -
273 result += cookie.toRawForm(QNetworkCookie::NameAndValueOnly); -
274 }
executed: }
Execution Count:14
14
275 return result;
executed: return result;
Execution Count:11
11
276 } -
277 -
278 case QNetworkRequest::SetCookieHeader: { -
279 QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(value); -
280 if (cookies.isEmpty() && value.userType() == qMetaTypeId<QNetworkCookie>())
partially evaluated: cookies.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: value.userType() == qMetaTypeId<QNetworkCookie>()
0-3
281 cookies << qvariant_cast<QNetworkCookie>(value);
never executed: cookies << qvariant_cast<QNetworkCookie>(value);
0
282 -
283 QByteArray result; -
284 bool first = true; -
285 for (QForeachContainer<__typeof__(cookies)> _container_(cookies); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QNetworkCookie &cookie = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
286 if (!first)
evaluated: !first
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
287 result += ", ";
executed: result += ", ";
Execution Count:1
1
288 first = false; -
289 result += cookie.toRawForm(QNetworkCookie::Full); -
290 }
executed: }
Execution Count:4
4
291 return result;
executed: return result;
Execution Count:3
3
292 } -
293 } -
294 -
295 return QByteArray();
never executed: return QByteArray();
0
296} -
297 -
298static QNetworkRequest::KnownHeaders parseHeaderName(const QByteArray &headerName) -
299{ -
300 -
301 -
302 switch (tolower(headerName.at(0))) { -
303 case 'c': -
304 if (qstricmp(headerName.constData(), "content-type") == 0)
evaluated: qstricmp(headerName.constData(), "content-type") == 0
TRUEFALSE
yes
Evaluation Count:766
yes
Evaluation Count:1157
766-1157
305 return QNetworkRequest::ContentTypeHeader;
executed: return QNetworkRequest::ContentTypeHeader;
Execution Count:766
766
306 else if (qstricmp(headerName.constData(), "content-length") == 0)
evaluated: qstricmp(headerName.constData(), "content-length") == 0
TRUEFALSE
yes
Evaluation Count:521
yes
Evaluation Count:636
521-636
307 return QNetworkRequest::ContentLengthHeader;
executed: return QNetworkRequest::ContentLengthHeader;
Execution Count:521
521
308 else if (qstricmp(headerName.constData(), "cookie") == 0)
evaluated: qstricmp(headerName.constData(), "cookie") == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:634
2-634
309 return QNetworkRequest::CookieHeader;
executed: return QNetworkRequest::CookieHeader;
Execution Count:2
2
310 break;
executed: break;
Execution Count:634
634
311 -
312 case 'l': -
313 if (qstricmp(headerName.constData(), "location") == 0)
evaluated: qstricmp(headerName.constData(), "location") == 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:277
38-277
314 return QNetworkRequest::LocationHeader;
executed: return QNetworkRequest::LocationHeader;
Execution Count:38
38
315 else if (qstricmp(headerName.constData(), "last-modified") == 0)
partially evaluated: qstricmp(headerName.constData(), "last-modified") == 0
TRUEFALSE
yes
Evaluation Count:277
no
Evaluation Count:0
0-277
316 return QNetworkRequest::LastModifiedHeader;
executed: return QNetworkRequest::LastModifiedHeader;
Execution Count:277
277
317 break;
never executed: break;
0
318 -
319 case 's': -
320 if (qstricmp(headerName.constData(), "set-cookie") == 0)
evaluated: qstricmp(headerName.constData(), "set-cookie") == 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:686
17-686
321 return QNetworkRequest::SetCookieHeader;
executed: return QNetworkRequest::SetCookieHeader;
Execution Count:17
17
322 else if (qstricmp(headerName.constData(), "server") == 0)
partially evaluated: qstricmp(headerName.constData(), "server") == 0
TRUEFALSE
yes
Evaluation Count:686
no
Evaluation Count:0
0-686
323 return QNetworkRequest::ServerHeader;
executed: return QNetworkRequest::ServerHeader;
Execution Count:686
686
324 break;
never executed: break;
0
325 -
326 case 'u': -
327 if (qstricmp(headerName.constData(), "user-agent") == 0)
partially evaluated: qstricmp(headerName.constData(), "user-agent") == 0
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
328 return QNetworkRequest::UserAgentHeader;
executed: return QNetworkRequest::UserAgentHeader;
Execution Count:8
8
329 break;
never executed: break;
0
330 } -
331 -
332 return QNetworkRequest::KnownHeaders(-1);
executed: return QNetworkRequest::KnownHeaders(-1);
Execution Count:2719
2719
333} -
334 -
335static QVariant parseHttpDate(const QByteArray &raw) -
336{ -
337 QDateTime dt = QNetworkHeadersPrivate::fromHttpDate(raw); -
338 if (dt.isValid())
partially evaluated: dt.isValid()
TRUEFALSE
yes
Evaluation Count:277
no
Evaluation Count:0
0-277
339 return dt;
executed: return dt;
Execution Count:277
277
340 return QVariant();
never executed: return QVariant();
0
341} -
342 -
343static QVariant parseCookieHeader(const QByteArray &raw) -
344{ -
345 QList<QNetworkCookie> result; -
346 QList<QByteArray> cookieList = raw.split(';'); -
347 for (QForeachContainer<__typeof__(cookieList)> _container_(cookieList); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QByteArray &cookie = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
348 QList<QNetworkCookie> parsed = QNetworkCookie::parseCookies(cookie.trimmed()); -
349 if (parsed.count() != 1)
partially evaluated: parsed.count() != 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
350 return QVariant();
never executed: return QVariant();
0
351 -
352 result += parsed; -
353 }
executed: }
Execution Count:3
3
354 -
355 return QVariant::fromValue(result);
executed: return QVariant::fromValue(result);
Execution Count:2
2
356} -
357 -
358static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QByteArray &value) -
359{ -
360 -
361 switch (header) { -
362 case QNetworkRequest::UserAgentHeader: -
363 case QNetworkRequest::ServerHeader: -
364 case QNetworkRequest::ContentTypeHeader: -
365 -
366 return QString::fromLatin1(value);
executed: return QString::fromLatin1(value);
Execution Count:1460
1460
367 -
368 case QNetworkRequest::ContentLengthHeader: { -
369 bool ok; -
370 qint64 result = value.trimmed().toLongLong(&ok); -
371 if (ok)
evaluated: ok
TRUEFALSE
yes
Evaluation Count:518
yes
Evaluation Count:2
2-518
372 return result;
executed: return result;
Execution Count:518
518
373 return QVariant();
executed: return QVariant();
Execution Count:2
2
374 } -
375 -
376 case QNetworkRequest::LocationHeader: { -
377 QUrl result = QUrl::fromEncoded(value, QUrl::StrictMode); -
378 if (result.isValid() && !result.scheme().isEmpty())
evaluated: result.isValid()
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:2
evaluated: !result.scheme().isEmpty()
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:1
1-36
379 return result;
executed: return result;
Execution Count:35
35
380 return QVariant();
executed: return QVariant();
Execution Count:3
3
381 } -
382 -
383 case QNetworkRequest::LastModifiedHeader: -
384 return parseHttpDate(value);
executed: return parseHttpDate(value);
Execution Count:277
277
385 -
386 case QNetworkRequest::CookieHeader: -
387 return parseCookieHeader(value);
executed: return parseCookieHeader(value);
Execution Count:2
2
388 -
389 case QNetworkRequest::SetCookieHeader: -
390 return QVariant::fromValue(QNetworkCookie::parseCookies(value));
executed: return QVariant::fromValue(QNetworkCookie::parseCookies(value));
Execution Count:17
17
391 -
392 default: -
393 qt_noop(); -
394 }
never executed: }
0
395 return QVariant();
never executed: return QVariant();
0
396} -
397 -
398QNetworkHeadersPrivate::RawHeadersList::ConstIterator -
399QNetworkHeadersPrivate::findRawHeader(const QByteArray &key) const -
400{ -
401 RawHeadersList::ConstIterator it = rawHeaders.constBegin(); -
402 RawHeadersList::ConstIterator end = rawHeaders.constEnd(); -
403 for ( ; it != end; ++it)
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:17836
yes
Evaluation Count:5297
5297-17836
404 if (qstricmp(it->first.constData(), key.constData()) == 0)
evaluated: qstricmp(it->first.constData(), key.constData()) == 0
TRUEFALSE
yes
Evaluation Count:985
yes
Evaluation Count:16851
985-16851
405 return it;
executed: return it;
Execution Count:985
985
406 -
407 return end;
executed: return end;
Execution Count:5297
5297
408} -
409 -
410QNetworkHeadersPrivate::RawHeadersList QNetworkHeadersPrivate::allRawHeaders() const -
411{ -
412 return rawHeaders;
executed: return rawHeaders;
Execution Count:20
20
413} -
414 -
415QList<QByteArray> QNetworkHeadersPrivate::rawHeadersKeys() const -
416{ -
417 QList<QByteArray> result; -
418 RawHeadersList::ConstIterator it = rawHeaders.constBegin(), -
419 end = rawHeaders.constEnd(); -
420 for ( ; it != end; ++it)
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:1057
yes
Evaluation Count:852
852-1057
421 result << it->first;
executed: result << it->first;
Execution Count:1057
1057
422 -
423 return result;
executed: return result;
Execution Count:852
852
424} -
425 -
426void QNetworkHeadersPrivate::setRawHeader(const QByteArray &key, const QByteArray &value) -
427{ -
428 if (key.isEmpty())
evaluated: key.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4863
2-4863
429 -
430 return;
executed: return;
Execution Count:2
2
431 -
432 setRawHeaderInternal(key, value); -
433 parseAndSetHeader(key, value); -
434}
executed: }
Execution Count:4863
4863
435void QNetworkHeadersPrivate::setAllRawHeaders(const RawHeadersList &list) -
436{ -
437 cookedHeaders.clear(); -
438 rawHeaders = list; -
439 -
440 RawHeadersList::ConstIterator it = rawHeaders.constBegin(); -
441 RawHeadersList::ConstIterator end = rawHeaders.constEnd(); -
442 for ( ; it != end; ++it)
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:171
yes
Evaluation Count:109
109-171
443 parseAndSetHeader(it->first, it->second);
executed: parseAndSetHeader(it->first, it->second);
Execution Count:171
171
444}
executed: }
Execution Count:109
109
445 -
446void QNetworkHeadersPrivate::setCookedHeader(QNetworkRequest::KnownHeaders header, -
447 const QVariant &value) -
448{ -
449 QByteArray name = headerName(header); -
450 if (name.isEmpty()) {
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:398
0-398
451 -
452 QMessageLogger("access/qnetworkrequest.cpp", 916, __PRETTY_FUNCTION__).warning("QNetworkRequest::setHeader: invalid header value KnownHeader(%d) received", header); -
453 return;
never executed: return;
0
454 } -
455 -
456 if (value.isNull()) {
evaluated: value.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:395
3-395
457 setRawHeaderInternal(name, QByteArray()); -
458 cookedHeaders.remove(header); -
459 } else {
executed: }
Execution Count:3
3
460 QByteArray rawValue = headerValue(header, value); -
461 if (rawValue.isEmpty()) {
partially evaluated: rawValue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:395
0-395
462 QMessageLogger("access/qnetworkrequest.cpp", 926, __PRETTY_FUNCTION__).warning("QNetworkRequest::setHeader: QVariant of type %s cannot be used with header %s", -
463 value.typeName(), name.constData()); -
464 return;
never executed: return;
0
465 } -
466 -
467 setRawHeaderInternal(name, rawValue); -
468 cookedHeaders.insert(header, value); -
469 }
executed: }
Execution Count:395
395
470} -
471 -
472void QNetworkHeadersPrivate::setRawHeaderInternal(const QByteArray &key, const QByteArray &value) -
473{ -
474 RawHeadersList::Iterator it = rawHeaders.begin(); -
475 while (it != rawHeaders.end()) {
evaluated: it != rawHeaders.end()
TRUEFALSE
yes
Evaluation Count:15480
yes
Evaluation Count:5261
5261-15480
476 if (qstricmp(it->first.constData(), key.constData()) == 0)
evaluated: qstricmp(it->first.constData(), key.constData()) == 0
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:15433
47-15433
477 it = rawHeaders.erase(it);
executed: it = rawHeaders.erase(it);
Execution Count:47
47
478 else -
479 ++it;
executed: ++it;
Execution Count:15433
15433
480 } -
481 -
482 if (value.isNull())
evaluated: value.isNull()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:5252
9-5252
483 return;
executed: return;
Execution Count:9
9
484 -
485 RawHeaderPair pair; -
486 pair.first = key; -
487 pair.second = value; -
488 rawHeaders.append(pair); -
489}
executed: }
Execution Count:5252
5252
490 -
491void QNetworkHeadersPrivate::parseAndSetHeader(const QByteArray &key, const QByteArray &value) -
492{ -
493 -
494 QNetworkRequest::KnownHeaders parsedKey = parseHeaderName(key); -
495 if (parsedKey != QNetworkRequest::KnownHeaders(-1)) {
evaluated: parsedKey != QNetworkRequest::KnownHeaders(-1)
TRUEFALSE
yes
Evaluation Count:2315
yes
Evaluation Count:2719
2315-2719
496 if (value.isNull()) {
partially evaluated: value.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2315
0-2315
497 cookedHeaders.remove(parsedKey); -
498 } else if (parsedKey == QNetworkRequest::ContentLengthHeader
evaluated: parsedKey == QNetworkRequest::ContentLengthHeader
TRUEFALSE
yes
Evaluation Count:521
yes
Evaluation Count:1794
never executed: }
0-1794
499 && cookedHeaders.contains(QNetworkRequest::ContentLengthHeader)) {
evaluated: cookedHeaders.contains(QNetworkRequest::ContentLengthHeader)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:520
1-520
500 -
501 -
502 } else {
executed: }
Execution Count:1
1
503 cookedHeaders.insert(parsedKey, parseHeaderValue(parsedKey, value)); -
504 }
executed: }
Execution Count:2314
2314
505 -
506 } -
507}
executed: }
Execution Count:5034
5034
508 -
509 -
510 -
511 -
512static int name_to_month(const char* month_str) -
513{ -
514 switch (month_str[0]) { -
515 case 'J': -
516 switch (month_str[1]) { -
517 case 'a': -
518 return 1;
executed: return 1;
Execution Count:24
24
519 case 'u': -
520 switch (month_str[2] ) { -
521 case 'n': -
522 return 6;
executed: return 6;
Execution Count:18
18
523 case 'l': -
524 return 7;
never executed: return 7;
0
525 } -
526 }
never executed: }
0
527 break;
never executed: break;
0
528 case 'F': -
529 return 2;
never executed: return 2;
0
530 case 'M': -
531 switch (month_str[2] ) { -
532 case 'r': -
533 return 3;
executed: return 3;
Execution Count:1
1
534 case 'y': -
535 return 5;
executed: return 5;
Execution Count:61
61
536 } -
537 break;
never executed: break;
0
538 case 'A': -
539 switch (month_str[1]) { -
540 case 'p': -
541 return 4;
never executed: return 4;
0
542 case 'u': -
543 return 8;
never executed: return 8;
0
544 } -
545 break;
never executed: break;
0
546 case 'O': -
547 return 10;
executed: return 10;
Execution Count:215
215
548 case 'S': -
549 return 9;
never executed: return 9;
0
550 case 'N': -
551 return 11;
executed: return 11;
Execution Count:14
14
552 case 'D': -
553 return 12;
never executed: return 12;
0
554 } -
555 -
556 return 0;
never executed: return 0;
0
557} -
558 -
559QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value) -
560{ -
561 -
562 -
563 -
564 -
565 -
566 -
567 int pos = value.indexOf(','); -
568 QDateTime dt; -
569 -
570 if (pos == -1) {
evaluated: pos == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:334
1-334
571 -
572 dt = QDateTime::fromString(QString::fromLatin1(value), Qt::TextDate); -
573 } else {
executed: }
Execution Count:1
1
574 -
575 -
576 if (pos == 3) {
evaluated: pos == 3
TRUEFALSE
yes
Evaluation Count:333
yes
Evaluation Count:1
1-333
577 char month_name[4]; -
578 int day, year, hour, minute, second; -
579 -
580 -
581 -
582 -
583 -
584 -
585 if (sscanf(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6)
partially evaluated: sscanf(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6
TRUEFALSE
yes
Evaluation Count:333
no
Evaluation Count:0
0-333
586 -
587 dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second));
executed: dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second));
Execution Count:333
333
588 } else {
executed: }
Execution Count:333
333
589 QLocale c = QLocale::c(); -
590 -
591 QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2); -
592 -
593 dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'")); -
594 }
executed: }
Execution Count:1
1
595 } -
596 -
597 -
598 if (dt.isValid())
partially evaluated: dt.isValid()
TRUEFALSE
yes
Evaluation Count:335
no
Evaluation Count:0
0-335
599 dt.setTimeSpec(Qt::UTC);
executed: dt.setTimeSpec(Qt::UTC);
Execution Count:335
335
600 return dt;
executed: return dt;
Execution Count:335
335
601} -
602 -
603QByteArray QNetworkHeadersPrivate::toHttpDate(const QDateTime &dt) -
604{ -
605 return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'")) 70
606 .toLatin1();
executed: return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'")) .toLatin1();
Execution Count:70
70
607} -
608 -
609 -
610 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial