OpenCoverage

qnetworkrequest.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkrequest.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qnetworkrequest.h"-
41#include "qnetworkrequest_p.h"-
42#include "qplatformdefs.h"-
43#include "qnetworkcookie.h"-
44#include "qsslconfiguration.h"-
45#include "QtCore/qshareddata.h"-
46#include "QtCore/qlocale.h"-
47#include "QtCore/qdatetime.h"-
48-
49#include <ctype.h>-
50#ifndef QT_NO_DATESTRING-
51# include <stdio.h>-
52#endif-
53-
54#include <algorithm>-
55-
56QT_BEGIN_NAMESPACE-
57-
58/*!-
59 \class QNetworkRequest-
60 \since 4.4-
61 \ingroup network-
62 \ingroup shared-
63 \inmodule QtNetwork-
64-
65 \brief The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.-
66-
67 QNetworkRequest is part of the Network Access API and is the class-
68 holding the information necessary to send a request over the-
69 network. It contains a URL and some ancillary information that can-
70 be used to modify the request.-
71-
72 \sa QNetworkReply, QNetworkAccessManager-
73*/-
74-
75/*!-
76 \enum QNetworkRequest::KnownHeaders-
77-
78 List of known header types that QNetworkRequest parses. Each known-
79 header is also represented in raw form with its full HTTP name.-
80-
81 \value ContentDispositionHeader Corresponds to the HTTP-
82 Content-Disposition header and contains a string containing the-
83 disposition type (for instance, attachment) and a parameter (for-
84 instance, filename).-
85-
86 \value ContentTypeHeader Corresponds to the HTTP Content-Type-
87 header and contains a string containing the media (MIME) type and-
88 any auxiliary data (for instance, charset).-
89-
90 \value ContentLengthHeader Corresponds to the HTTP Content-Length-
91 header and contains the length in bytes of the data transmitted.-
92-
93 \value LocationHeader Corresponds to the HTTP Location-
94 header and contains a URL representing the actual location of the-
95 data, including the destination URL in case of redirections.-
96-
97 \value LastModifiedHeader Corresponds to the HTTP Last-Modified-
98 header and contains a QDateTime representing the last modification-
99 date of the contents.-
100-
101 \value CookieHeader Corresponds to the HTTP Cookie header-
102 and contains a QList<QNetworkCookie> representing the cookies to-
103 be sent back to the server.-
104-
105 \value SetCookieHeader Corresponds to the HTTP Set-Cookie-
106 header and contains a QList<QNetworkCookie> representing the-
107 cookies sent by the server to be stored locally.-
108-
109 \value UserAgentHeader The User-Agent header sent by HTTP clients.-
110-
111 \value ServerHeader The Server header received by HTTP clients.-
112-
113 \sa header(), setHeader(), rawHeader(), setRawHeader()-
114*/-
115-
116/*!-
117 \enum QNetworkRequest::Attribute-
118 \since 4.7-
119-
120 Attribute codes for the QNetworkRequest and QNetworkReply.-
121-
122 Attributes are extra meta-data that are used to control the-
123 behavior of the request and to pass further information from the-
124 reply back to the application. Attributes are also extensible,-
125 allowing custom implementations to pass custom values.-
126-
127 The following table explains what the default attribute codes are,-
128 the QVariant types associated, the default value if said attribute-
129 is missing and whether it's used in requests or replies.-
130-
131 \value HttpStatusCodeAttribute-
132 Replies only, type: QMetaType::Int (no default)-
133 Indicates the HTTP status code received from the HTTP server-
134 (like 200, 304, 404, 401, etc.). If the connection was not-
135 HTTP-based, this attribute will not be present.-
136-
137 \value HttpReasonPhraseAttribute-
138 Replies only, type: QMetaType::QByteArray (no default)-
139 Indicates the HTTP reason phrase as received from the HTTP-
140 server (like "Ok", "Found", "Not Found", "Access Denied",-
141 etc.) This is the human-readable representation of the status-
142 code (see above). If the connection was not HTTP-based, this-
143 attribute will not be present.-
144-
145 \value RedirectionTargetAttribute-
146 Replies only, type: QMetaType::QUrl (no default)-
147 If present, it indicates that the server is redirecting the-
148 request to a different URL. The Network Access API does not by-
149 default follow redirections: the application can-
150 determine if the requested redirection should be allowed,-
151 according to its security policies, or it can set-
152 QNetworkRequest::FollowRedirectsAttribute to true (in which case-
153 the redirection will be followed and this attribute will not-
154 be present in the reply).-
155 The returned URL might be relative. Use QUrl::resolved()-
156 to create an absolute URL out of it.-
157-
158 \value ConnectionEncryptedAttribute-
159 Replies only, type: QMetaType::Bool (default: false)-
160 Indicates whether the data was obtained through an encrypted-
161 (secure) connection.-
162-
163 \value CacheLoadControlAttribute-
164 Requests only, type: QMetaType::Int (default: QNetworkRequest::PreferNetwork)-
165 Controls how the cache should be accessed. The possible values-
166 are those of QNetworkRequest::CacheLoadControl. Note that the-
167 default QNetworkAccessManager implementation does not support-
168 caching. However, this attribute may be used by certain-
169 backends to modify their requests (for example, for caching proxies).-
170-
171 \value CacheSaveControlAttribute-
172 Requests only, type: QMetaType::Bool (default: true)-
173 Controls if the data obtained should be saved to cache for-
174 future uses. If the value is false, the data obtained will not-
175 be automatically cached. If true, data may be cached, provided-
176 it is cacheable (what is cacheable depends on the protocol-
177 being used).-
178-
179 \value SourceIsFromCacheAttribute-
180 Replies only, type: QMetaType::Bool (default: false)-
181 Indicates whether the data was obtained from cache-
182 or not.-
183-
184 \value DoNotBufferUploadDataAttribute-
185 Requests only, type: QMetaType::Bool (default: false)-
186 Indicates whether the QNetworkAccessManager code is-
187 allowed to buffer the upload data, e.g. when doing a HTTP POST.-
188 When using this flag with sequential upload data, the ContentLengthHeader-
189 header must be set.-
190-
191 \value HttpPipeliningAllowedAttribute-
192 Requests only, type: QMetaType::Bool (default: false)-
193 Indicates whether the QNetworkAccessManager code is-
194 allowed to use HTTP pipelining with this request.-
195-
196 \value HttpPipeliningWasUsedAttribute-
197 Replies only, type: QMetaType::Bool-
198 Indicates whether the HTTP pipelining was used for receiving-
199 this reply.-
200-
201 \value CustomVerbAttribute-
202 Requests only, type: QMetaType::QByteArray-
203 Holds the value for the custom HTTP verb to send (destined for usage-
204 of other verbs than GET, POST, PUT and DELETE). This verb is set-
205 when calling QNetworkAccessManager::sendCustomRequest().-
206-
207 \value CookieLoadControlAttribute-
208 Requests only, type: QMetaType::Int (default: QNetworkRequest::Automatic)-
209 Indicates whether to send 'Cookie' headers in the request.-
210 This attribute is set to false by Qt WebKit when creating a cross-origin-
211 XMLHttpRequest where withCredentials has not been set explicitly to true by the-
212 Javascript that created the request.-
213 See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag}{here} for more information.-
214 (This value was introduced in 4.7.)-
215-
216 \value CookieSaveControlAttribute-
217 Requests only, type: QMetaType::Int (default: QNetworkRequest::Automatic)-
218 Indicates whether to save 'Cookie' headers received from the server in reply-
219 to the request.-
220 This attribute is set to false by Qt WebKit when creating a cross-origin-
221 XMLHttpRequest where withCredentials has not been set explicitly to true by the-
222 Javascript that created the request.-
223 See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag} {here} for more information.-
224 (This value was introduced in 4.7.)-
225-
226 \value AuthenticationReuseAttribute-
227 Requests only, type: QMetaType::Int (default: QNetworkRequest::Automatic)-
228 Indicates whether to use cached authorization credentials in the request,-
229 if available. If this is set to QNetworkRequest::Manual and the authentication-
230 mechanism is 'Basic' or 'Digest', Qt will not send an an 'Authorization' HTTP-
231 header with any cached credentials it may have for the request's URL.-
232 This attribute is set to QNetworkRequest::Manual by Qt WebKit when creating a cross-origin-
233 XMLHttpRequest where withCredentials has not been set explicitly to true by the-
234 Javascript that created the request.-
235 See \l{http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag} {here} for more information.-
236 (This value was introduced in 4.7.)-
237-
238 \omitvalue MaximumDownloadBufferSizeAttribute-
239-
240 \omitvalue DownloadBufferAttribute-
241-
242 \omitvalue SynchronousRequestAttribute-
243-
244 \value BackgroundRequestAttribute-
245 Type: QMetaType::Bool (default: false)-
246 Indicates that this is a background transfer, rather than a user initiated-
247 transfer. Depending on the platform, background transfers may be subject-
248 to different policies.-
249 The QNetworkSession ConnectInBackground property will be set according to-
250 this attribute.-
251-
252 \value SpdyAllowedAttribute-
253 Requests only, type: QMetaType::Bool (default: false)-
254 Indicates whether the QNetworkAccessManager code is-
255 allowed to use SPDY with this request. This applies only-
256 to SSL requests, and depends on the server supporting SPDY.-
257-
258 \value SpdyWasUsedAttribute-
259 Replies only, type: QMetaType::Bool-
260 Indicates whether SPDY was used for receiving-
261 this reply.-
262-
263 \value EmitAllUploadProgressSignalsAttribute-
264 Requests only, type: QMetaType::Bool (default: false)-
265 Indicates whether all upload signals should be emitted.-
266 By default, the uploadProgress signal is emitted only-
267 in 100 millisecond intervals.-
268 (This value was introduced in 5.5.)-
269-
270 \value FollowRedirectsAttribute-
271 Requests only, type: QMetaType::Bool (default: false)-
272 Indicates whether the Network Access API should automatically follow a-
273 HTTP redirect response or not. Currently redirects that are insecure,-
274 that is redirecting from "https" to "http" protocol, are not allowed.-
275 (This value was introduced in 5.6.)-
276-
277 \value User-
278 Special type. Additional information can be passed in-
279 QVariants with types ranging from User to UserMax. The default-
280 implementation of Network Access will ignore any request-
281 attributes in this range and it will not produce any-
282 attributes in this range in replies. The range is reserved for-
283 extensions of QNetworkAccessManager.-
284-
285 \value UserMax-
286 Special type. See User.-
287*/-
288-
289/*!-
290 \enum QNetworkRequest::CacheLoadControl-
291-
292 Controls the caching mechanism of QNetworkAccessManager.-
293-
294 \value AlwaysNetwork always load from network and do not-
295 check if the cache has a valid entry (similar to the-
296 "Reload" feature in browsers); in addition, force intermediate-
297 caches to re-validate.-
298-
299 \value PreferNetwork default value; load from the network-
300 if the cached entry is older than the network entry. This will never-
301 return stale data from the cache, but revalidate resources that-
302 have become stale.-
303-
304 \value PreferCache load from cache if available,-
305 otherwise load from network. Note that this can return possibly-
306 stale (but not expired) items from cache.-
307-
308 \value AlwaysCache only load from cache, indicating error-
309 if the item was not cached (i.e., off-line mode)-
310*/-
311-
312/*!-
313 \enum QNetworkRequest::LoadControl-
314 \since 4.7-
315-
316 Indicates if an aspect of the request's loading mechanism has been-
317 manually overridden, e.g. by Qt WebKit.-
318-
319 \value Automatic default value: indicates default behaviour.-
320-
321 \value Manual indicates behaviour has been manually overridden.-
322*/-
323-
324class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate-
325{-
326public:-
327 static const int maxRedirectCount = 50;-
328 inline QNetworkRequestPrivate()-
329 : priority(QNetworkRequest::NormalPriority)-
330#ifndef QT_NO_SSL-
331 , sslConfiguration(0)-
332#endif-
333 , maxRedirectsAllowed(maxRedirectCount)-
334 { qRegisterMetaType<QNetworkRequest>(); }
executed 3129 times by 11 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
3129
335 ~QNetworkRequestPrivate()-
336 {-
337#ifndef QT_NO_SSL-
338 delete sslConfiguration;-
339#endif-
340 }
executed 3384 times by 12 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
  • tst_spdy - unknown status
3384
341-
342-
343 QNetworkRequestPrivate(const QNetworkRequestPrivate &other)-
344 : QSharedData(other), QNetworkHeadersPrivate(other)-
345 {-
346 url = other.url;-
347 priority = other.priority;-
348 maxRedirectsAllowed = other.maxRedirectsAllowed;-
349#ifndef QT_NO_SSL-
350 sslConfiguration = 0;-
351 if (other.sslConfiguration)
other.sslConfigurationDescription
TRUEevaluated 102 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 154 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
102-154
352 sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
executed 102 times by 2 tests: sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
102
353#endif-
354 }
executed 256 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
256
355-
356 inline bool operator==(const QNetworkRequestPrivate &other) const-
357 {-
358 return url == other.url &&
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes && maxRedirectsAllowed == other.maxRedirectsAllowed;
0
359 priority == other.priority &&
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes && maxRedirectsAllowed == other.maxRedirectsAllowed;
0
360 rawHeaders == other.rawHeaders &&
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes && maxRedirectsAllowed == other.maxRedirectsAllowed;
0
361 attributes == other.attributes &&
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes && maxRedirectsAllowed == other.maxRedirectsAllowed;
0
362 maxRedirectsAllowed == other.maxRedirectsAllowed;
never executed: return url == other.url && priority == other.priority && rawHeaders == other.rawHeaders && attributes == other.attributes && maxRedirectsAllowed == other.maxRedirectsAllowed;
0
363 // don't compare cookedHeaders-
364 }-
365-
366 QUrl url;-
367 QNetworkRequest::Priority priority;-
368#ifndef QT_NO_SSL-
369 mutable QSslConfiguration *sslConfiguration;-
370#endif-
371 int maxRedirectsAllowed;-
372};-
373-
374/*!-
375 Constructs a QNetworkRequest object with \a url as the URL to be-
376 requested.-
377-
378 \sa url(), setUrl()-
379*/-
380QNetworkRequest::QNetworkRequest(const QUrl &url)-
381 : d(new QNetworkRequestPrivate)-
382{-
383 d->url = url;-
384}
executed 3129 times by 11 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
3129
385-
386/*!-
387 Creates a copy of \a other.-
388*/-
389QNetworkRequest::QNetworkRequest(const QNetworkRequest &other)-
390 : d(other.d)-
391{-
392}
executed 1181 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1181
393-
394/*!-
395 Disposes of the QNetworkRequest object.-
396*/-
397QNetworkRequest::~QNetworkRequest()-
398{-
399 // QSharedDataPointer auto deletes-
400 d = 0;-
401}
executed 4307 times by 12 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
  • tst_spdy - unknown status
4307
402-
403/*!-
404 Returns \c true if this object is the same as \a other (i.e., if they-
405 have the same URL, same headers and same meta-data settings).-
406-
407 \sa operator!=()-
408*/-
409bool QNetworkRequest::operator==(const QNetworkRequest &other) const-
410{-
411 return d == other.d || *d == *other.d;
executed 1 time by 1 test: return d == other.d || *d == *other.d;
Executed by:
  • tst_QNetworkReply
1
412}-
413-
414/*!-
415 \fn bool QNetworkRequest::operator!=(const QNetworkRequest &other) const-
416-
417 Returns \c false if this object is not the same as \a other.-
418-
419 \sa operator==()-
420*/-
421-
422/*!-
423 Creates a copy of \a other-
424*/-
425QNetworkRequest &QNetworkRequest::operator=(const QNetworkRequest &other)-
426{-
427 d = other.d;-
428 return *this;
executed 1956 times by 10 tests: return *this;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
1956
429}-
430-
431/*!-
432 \fn void QNetworkRequest::swap(QNetworkRequest &other)-
433 \since 5.0-
434-
435 Swaps this network request with \a other. This function is very-
436 fast and never fails.-
437*/-
438-
439/*!-
440 Returns the URL this network request is referring to.-
441-
442 \sa setUrl()-
443*/-
444QUrl QNetworkRequest::url() const-
445{-
446 return d->url;
executed 6076 times by 11 tests: return d->url;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
6076
447}-
448-
449/*!-
450 Sets the URL this network request is referring to be \a url.-
451-
452 \sa url()-
453*/-
454void QNetworkRequest::setUrl(const QUrl &url)-
455{-
456 d->url = url;-
457}
executed 29 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
29
458-
459/*!-
460 Returns the value of the known network header \a header if it is-
461 present in this request. If it is not present, returns QVariant()-
462 (i.e., an invalid variant).-
463-
464 \sa KnownHeaders, rawHeader(), setHeader()-
465*/-
466QVariant QNetworkRequest::header(KnownHeaders header) const-
467{-
468 return d->cookedHeaders.value(header);
executed 1084 times by 9 tests: return d->cookedHeaders.value(header);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1084
469}-
470-
471/*!-
472 Sets the value of the known header \a header to be \a value,-
473 overriding any previously set headers. This operation also sets-
474 the equivalent raw HTTP header.-
475-
476 \sa KnownHeaders, setRawHeader(), header()-
477*/-
478void QNetworkRequest::setHeader(KnownHeaders header, const QVariant &value)-
479{-
480 d->setCookedHeader(header, value);-
481}
executed 212 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
212
482-
483/*!-
484 Returns \c true if the raw header \a headerName is present in this-
485 network request.-
486-
487 \sa rawHeader(), setRawHeader()-
488*/-
489bool QNetworkRequest::hasRawHeader(const QByteArray &headerName) const-
490{-
491 return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
executed 768 times by 8 tests: return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
768
492}-
493-
494/*!-
495 Returns the raw form of header \a headerName. If no such header is-
496 present, an empty QByteArray is returned, which may be-
497 indistinguishable from a header that is present but has no content-
498 (use hasRawHeader() to find out if the header exists or not).-
499-
500 Raw headers can be set with setRawHeader() or with setHeader().-
501-
502 \sa header(), setRawHeader()-
503*/-
504QByteArray QNetworkRequest::rawHeader(const QByteArray &headerName) const-
505{-
506 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it =-
507 d->findRawHeader(headerName);-
508 if (it != d->rawHeaders.constEnd())
it != d->rawHeaders.constEnd()Description
TRUEevaluated 376 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
4-376
509 return it->second;
executed 376 times by 4 tests: return it->second;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
376
510 return QByteArray();
executed 4 times by 1 test: return QByteArray();
Executed by:
  • tst_qnetworkrequest - unknown status
4
511}-
512-
513/*!-
514 Returns a list of all raw headers that are set in this network-
515 request. The list is in the order that the headers were set.-
516-
517 \sa hasRawHeader(), rawHeader()-
518*/-
519QList<QByteArray> QNetworkRequest::rawHeaderList() const-
520{-
521 return d->rawHeadersKeys();
executed 886 times by 9 tests: return d->rawHeadersKeys();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
886
522}-
523-
524/*!-
525 Sets the header \a headerName to be of value \a headerValue. If \a-
526 headerName corresponds to a known header (see-
527 QNetworkRequest::KnownHeaders), the raw format will be parsed and-
528 the corresponding "cooked" header will be set as well.-
529-
530 For example:-
531 \snippet code/src_network_access_qnetworkrequest.cpp 0-
532-
533 will also set the known header LastModifiedHeader to be the-
534 QDateTime object of the parsed date.-
535-
536 \note Setting the same header twice overrides the previous-
537 setting. To accomplish the behaviour of multiple HTTP headers of-
538 the same name, you should concatenate the two values, separating-
539 them with a comma (",") and set one single raw header.-
540-
541 \sa KnownHeaders, setHeader(), hasRawHeader(), rawHeader()-
542*/-
543void QNetworkRequest::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)-
544{-
545 d->setRawHeader(headerName, headerValue);-
546}
executed 198 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
198
547-
548/*!-
549 Returns the attribute associated with the code \a code. If the-
550 attribute has not been set, it returns \a defaultValue.-
551-
552 \note This function does not apply the defaults listed in-
553 QNetworkRequest::Attribute.-
554-
555 \sa setAttribute(), QNetworkRequest::Attribute-
556*/-
557QVariant QNetworkRequest::attribute(Attribute code, const QVariant &defaultValue) const-
558{-
559 return d->attributes.value(code, defaultValue);
executed 10121 times by 9 tests: return d->attributes.value(code, defaultValue);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
10121
560}-
561-
562/*!-
563 Sets the attribute associated with code \a code to be value \a-
564 value. If the attribute is already set, the previous value is-
565 discarded. In special, if \a value is an invalid QVariant, the-
566 attribute is unset.-
567-
568 \sa attribute(), QNetworkRequest::Attribute-
569*/-
570void QNetworkRequest::setAttribute(Attribute code, const QVariant &value)-
571{-
572 if (value.isValid())
value.isValid()Description
TRUEevaluated 334 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-334
573 d->attributes.insert(code, value);
executed 334 times by 5 tests: d->attributes.insert(code, value);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
334
574 else-
575 d->attributes.remove(code);
never executed: d->attributes.remove(code);
0
576}-
577-
578#ifndef QT_NO_SSL-
579/*!-
580 Returns this network request's SSL configuration. By default, no-
581 SSL settings are specified.-
582-
583 \sa setSslConfiguration()-
584*/-
585QSslConfiguration QNetworkRequest::sslConfiguration() const-
586{-
587 if (!d->sslConfiguration)
!d->sslConfigurationDescription
TRUEevaluated 814 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 411 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
411-814
588 d->sslConfiguration = new QSslConfiguration(QSslConfiguration::defaultConfiguration());
executed 814 times by 8 tests: d->sslConfiguration = new QSslConfiguration(QSslConfiguration::defaultConfiguration());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
814
589 return *d->sslConfiguration;
executed 1225 times by 8 tests: return *d->sslConfiguration;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1225
590}-
591-
592/*!-
593 Sets this network request's SSL configuration to be \a config. The-
594 settings that apply are the private key, the local certificate,-
595 the SSL protocol (SSLv2, SSLv3, TLSv1.0 where applicable), the CA-
596 certificates and the ciphers that the SSL backend is allowed to-
597 use.-
598-
599 By default, no SSL configuration is set, which allows the backends-
600 to choose freely what configuration is best for them.-
601-
602 \sa sslConfiguration(), QSslConfiguration::defaultConfiguration()-
603*/-
604void QNetworkRequest::setSslConfiguration(const QSslConfiguration &config)-
605{-
606 if (!d->sslConfiguration)
!d->sslConfigurationDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-46
607 d->sslConfiguration = new QSslConfiguration(config);
executed 46 times by 1 test: d->sslConfiguration = new QSslConfiguration(config);
Executed by:
  • tst_QNetworkReply
46
608 else-
609 *d->sslConfiguration = config;
executed 1 time by 1 test: *d->sslConfiguration = config;
Executed by:
  • tst_QNetworkReply
1
610}-
611#endif-
612-
613/*!-
614 \since 4.6-
615-
616 Allows setting a reference to the \a object initiating-
617 the request.-
618-
619 For example Qt WebKit sets the originating object to the-
620 QWebFrame that initiated the request.-
621-
622 \sa originatingObject()-
623*/-
624void QNetworkRequest::setOriginatingObject(QObject *object)-
625{-
626 d->originatingObject = object;-
627}
executed 1 time by 1 test: end of block
Executed by:
  • tst_qnetworkrequest - unknown status
1
628-
629/*!-
630 \since 4.6-
631-
632 Returns a reference to the object that initiated this-
633 network request; returns 0 if not set or the object has-
634 been destroyed.-
635-
636 \sa setOriginatingObject()-
637*/-
638QObject *QNetworkRequest::originatingObject() const-
639{-
640 return d->originatingObject.data();
executed 3 times by 1 test: return d->originatingObject.data();
Executed by:
  • tst_qnetworkrequest - unknown status
3
641}-
642-
643/*!-
644 \since 4.7-
645-
646 Return the priority of this request.-
647-
648 \sa setPriority()-
649*/-
650QNetworkRequest::Priority QNetworkRequest::priority() const-
651{-
652 return d->priority;
executed 887 times by 8 tests: return d->priority;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
887
653}-
654-
655/*! \enum QNetworkRequest::Priority-
656-
657 \since 4.7-
658-
659 This enum lists the possible network request priorities.-
660-
661 \value HighPriority High priority-
662 \value NormalPriority Normal priority-
663 \value LowPriority Low priority-
664 */-
665-
666/*!-
667 \since 4.7-
668-
669 Set the priority of this request to \a priority.-
670-
671 \note The \a priority is only a hint to the network access-
672 manager. It can use it or not. Currently it is used for HTTP to-
673 decide which request should be sent first to a server.-
674-
675 \sa priority()-
676*/-
677void QNetworkRequest::setPriority(Priority priority)-
678{-
679 d->priority = priority;-
680}
never executed: end of block
0
681-
682/*!-
683 \since 5.6-
684-
685 Returns the maximum number of redirects allowed to be followed for this-
686 request.-
687-
688 \sa setMaximumRedirectsAllowed()-
689*/-
690int QNetworkRequest::maximumRedirectsAllowed() const-
691{-
692 return d->maxRedirectsAllowed;
executed 891 times by 8 tests: return d->maxRedirectsAllowed;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
891
693}-
694-
695/*!-
696 \since 5.6-
697-
698 Sets the maximum number of redirects allowed to be followed for this-
699 request to \a maxRedirectsAllowed.-
700-
701 \sa maximumRedirectsAllowed()-
702*/-
703void QNetworkRequest::setMaximumRedirectsAllowed(int maxRedirectsAllowed)-
704{-
705 d->maxRedirectsAllowed = maxRedirectsAllowed;-
706}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
707-
708static QByteArray headerName(QNetworkRequest::KnownHeaders header)-
709{-
710 switch (header) {-
711 case QNetworkRequest::ContentTypeHeader:
executed 94 times by 4 tests: case QNetworkRequest::ContentTypeHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
94
712 return "Content-Type";
executed 94 times by 4 tests: return "Content-Type";
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
94
713-
714 case QNetworkRequest::ContentLengthHeader:
executed 252 times by 5 tests: case QNetworkRequest::ContentLengthHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
252
715 return "Content-Length";
executed 252 times by 5 tests: return "Content-Length";
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
252
716-
717 case QNetworkRequest::LocationHeader:
executed 3 times by 1 test: case QNetworkRequest::LocationHeader:
Executed by:
  • tst_qnetworkrequest - unknown status
3
718 return "Location";
executed 3 times by 1 test: return "Location";
Executed by:
  • tst_qnetworkrequest - unknown status
3
719-
720 case QNetworkRequest::LastModifiedHeader:
executed 59 times by 3 tests: case QNetworkRequest::LastModifiedHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
59
721 return "Last-Modified";
executed 59 times by 3 tests: return "Last-Modified";
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
59
722-
723 case QNetworkRequest::CookieHeader:
executed 11 times by 2 tests: case QNetworkRequest::CookieHeader:
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
11
724 return "Cookie";
executed 11 times by 2 tests: return "Cookie";
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
11
725-
726 case QNetworkRequest::SetCookieHeader:
executed 3 times by 1 test: case QNetworkRequest::SetCookieHeader:
Executed by:
  • tst_qnetworkrequest - unknown status
3
727 return "Set-Cookie";
executed 3 times by 1 test: return "Set-Cookie";
Executed by:
  • tst_qnetworkrequest - unknown status
3
728-
729 case QNetworkRequest::ContentDispositionHeader:
executed 36 times by 2 tests: case QNetworkRequest::ContentDispositionHeader:
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
36
730 return "Content-Disposition";
executed 36 times by 2 tests: return "Content-Disposition";
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
36
731-
732 case QNetworkRequest::UserAgentHeader:
executed 1 time by 1 test: case QNetworkRequest::UserAgentHeader:
Executed by:
  • tst_QNetworkReply
1
733 return "User-Agent";
executed 1 time by 1 test: return "User-Agent";
Executed by:
  • tst_QNetworkReply
1
734-
735 case QNetworkRequest::ServerHeader:
never executed: case QNetworkRequest::ServerHeader:
0
736 return "Server";
never executed: return "Server";
0
737-
738 // no default:-
739 // if new values are added, this will generate a compiler warning-
740 }-
741-
742 return QByteArray();
never executed: return QByteArray();
0
743}-
744-
745static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value)-
746{-
747 switch (header) {-
748 case QNetworkRequest::ContentTypeHeader:
executed 93 times by 4 tests: case QNetworkRequest::ContentTypeHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
93
749 case QNetworkRequest::ContentLengthHeader:
executed 251 times by 5 tests: case QNetworkRequest::ContentLengthHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
251
750 case QNetworkRequest::ContentDispositionHeader:
executed 36 times by 2 tests: case QNetworkRequest::ContentDispositionHeader:
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
36
751 case QNetworkRequest::UserAgentHeader:
executed 1 time by 1 test: case QNetworkRequest::UserAgentHeader:
Executed by:
  • tst_QNetworkReply
1
752 case QNetworkRequest::ServerHeader:
never executed: case QNetworkRequest::ServerHeader:
0
753 return value.toByteArray();
executed 381 times by 5 tests: return value.toByteArray();
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
381
754-
755 case QNetworkRequest::LocationHeader:
executed 3 times by 1 test: case QNetworkRequest::LocationHeader:
Executed by:
  • tst_qnetworkrequest - unknown status
3
756 switch (value.userType()) {-
757 case QMetaType::QUrl:
executed 1 time by 1 test: case QMetaType::QUrl:
Executed by:
  • tst_qnetworkrequest - unknown status
1
758 return value.toUrl().toEncoded();
executed 1 time by 1 test: return value.toUrl().toEncoded();
Executed by:
  • tst_qnetworkrequest - unknown status
1
759-
760 default:
executed 2 times by 1 test: default:
Executed by:
  • tst_qnetworkrequest - unknown status
2
761 return value.toByteArray();
executed 2 times by 1 test: return value.toByteArray();
Executed by:
  • tst_qnetworkrequest - unknown status
2
762 }-
763-
764 case QNetworkRequest::LastModifiedHeader:
executed 57 times by 3 tests: case QNetworkRequest::LastModifiedHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
57
765 switch (value.userType()) {-
766 case QMetaType::QDate:
executed 1 time by 1 test: case QMetaType::QDate:
Executed by:
  • tst_qnetworkrequest - unknown status
1
767 case QMetaType::QDateTime:
executed 56 times by 3 tests: case QMetaType::QDateTime:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
56
768 // generate RFC 1123/822 dates:-
769 return QNetworkHeadersPrivate::toHttpDate(value.toDateTime());
executed 57 times by 3 tests: return QNetworkHeadersPrivate::toHttpDate(value.toDateTime());
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
57
770-
771 default:
never executed: default:
0
772 return value.toByteArray();
never executed: return value.toByteArray();
0
773 }-
774-
775 case QNetworkRequest::CookieHeader: {
executed 11 times by 2 tests: case QNetworkRequest::CookieHeader:
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
11
776 QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(value);-
777 if (cookies.isEmpty() && value.userType() == qMetaTypeId<QNetworkCookie>())
cookies.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
value.userType...tworkCookie>()Description
TRUEnever evaluated
FALSEnever evaluated
0-11
778 cookies << qvariant_cast<QNetworkCookie>(value);
never executed: cookies << qvariant_cast<QNetworkCookie>(value);
0
779-
780 QByteArray result;-
781 bool first = true;-
782 for (const QNetworkCookie &cookie : qAsConst(cookies)) {-
783 if (!first)
!firstDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
3-11
784 result += "; ";
executed 3 times by 2 tests: result += "; ";
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
3
785 first = false;-
786 result += cookie.toRawForm(QNetworkCookie::NameAndValueOnly);-
787 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
14
788 return result;
executed 11 times by 2 tests: return result;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
11
789 }-
790-
791 case QNetworkRequest::SetCookieHeader: {
executed 3 times by 1 test: case QNetworkRequest::SetCookieHeader:
Executed by:
  • tst_qnetworkrequest - unknown status
3
792 QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(value);-
793 if (cookies.isEmpty() && value.userType() == qMetaTypeId<QNetworkCookie>())
cookies.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
value.userType...tworkCookie>()Description
TRUEnever evaluated
FALSEnever evaluated
0-3
794 cookies << qvariant_cast<QNetworkCookie>(value);
never executed: cookies << qvariant_cast<QNetworkCookie>(value);
0
795-
796 QByteArray result;-
797 bool first = true;-
798 for (const QNetworkCookie &cookie : qAsConst(cookies)) {-
799 if (!first)
!firstDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
1-3
800 result += ", ";
executed 1 time by 1 test: result += ", ";
Executed by:
  • tst_qnetworkrequest - unknown status
1
801 first = false;-
802 result += cookie.toRawForm(QNetworkCookie::Full);-
803 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qnetworkrequest - unknown status
4
804 return result;
executed 3 times by 1 test: return result;
Executed by:
  • tst_qnetworkrequest - unknown status
3
805 }-
806 }-
807-
808 return QByteArray();
never executed: return QByteArray();
0
809}-
810-
811static int parseHeaderName(const QByteArray &headerName)-
812{-
813 if (headerName.isEmpty())
headerName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 5862 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
0-5862
814 return -1;
never executed: return -1;
0
815-
816 switch (tolower(headerName.at(0))) {-
817 case 'c':
executed 2183 times by 7 tests: case 'c':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
2183
818 if (qstricmp(headerName.constData(), "content-type") == 0)
qstricmp(heade...nt-type") == 0Description
TRUEevaluated 917 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 1266 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
917-1266
819 return QNetworkRequest::ContentTypeHeader;
executed 917 times by 6 tests: return QNetworkRequest::ContentTypeHeader;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
917
820 else if (qstricmp(headerName.constData(), "content-length") == 0)
qstricmp(heade...-length") == 0Description
TRUEevaluated 590 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 676 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
590-676
821 return QNetworkRequest::ContentLengthHeader;
executed 590 times by 7 tests: return QNetworkRequest::ContentLengthHeader;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
590
822 else if (qstricmp(headerName.constData(), "cookie") == 0)
qstricmp(heade..."cookie") == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
FALSEevaluated 674 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
2-674
823 return QNetworkRequest::CookieHeader;
executed 2 times by 1 test: return QNetworkRequest::CookieHeader;
Executed by:
  • tst_qnetworkrequest - unknown status
2
824 break;
executed 674 times by 6 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
674
825-
826 case 'l':
executed 360 times by 6 tests: case 'l':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
360
827 if (qstricmp(headerName.constData(), "location") == 0)
qstricmp(heade...ocation") == 0Description
TRUEevaluated 47 times by 3 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 313 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
47-313
828 return QNetworkRequest::LocationHeader;
executed 47 times by 3 tests: return QNetworkRequest::LocationHeader;
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
47
829 else if (qstricmp(headerName.constData(), "last-modified") == 0)
qstricmp(heade...odified") == 0Description
TRUEevaluated 313 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEnever evaluated
0-313
830 return QNetworkRequest::LastModifiedHeader;
executed 313 times by 5 tests: return QNetworkRequest::LastModifiedHeader;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
313
831 break;
never executed: break;
0
832-
833 case 's':
executed 851 times by 7 tests: case 's':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
851
834 if (qstricmp(headerName.constData(), "set-cookie") == 0)
qstricmp(heade...-cookie") == 0Description
TRUEevaluated 19 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 832 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
19-832
835 return QNetworkRequest::SetCookieHeader;
executed 19 times by 3 tests: return QNetworkRequest::SetCookieHeader;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
19
836 else if (qstricmp(headerName.constData(), "server") == 0)
qstricmp(heade..."server") == 0Description
TRUEevaluated 831 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-831
837 return QNetworkRequest::ServerHeader;
executed 831 times by 5 tests: return QNetworkRequest::ServerHeader;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
831
838 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkReply
1
839-
840 case 'u':
executed 9 times by 2 tests: case 'u':
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
9
841 if (qstricmp(headerName.constData(), "user-agent") == 0)
qstricmp(heade...r-agent") == 0Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEnever evaluated
0-9
842 return QNetworkRequest::UserAgentHeader;
executed 9 times by 2 tests: return QNetworkRequest::UserAgentHeader;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
9
843 break;
never executed: break;
0
844 }-
845-
846 return -1; // nothing found
executed 3134 times by 8 tests: return -1;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
3134
847}-
848-
849static QVariant parseHttpDate(const QByteArray &raw)-
850{-
851 QDateTime dt = QNetworkHeadersPrivate::fromHttpDate(raw);-
852 if (dt.isValid())
dt.isValid()Description
TRUEevaluated 313 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEnever evaluated
0-313
853 return dt;
executed 313 times by 5 tests: return dt;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
313
854 return QVariant(); // transform an invalid QDateTime into a null QVariant
never executed: return QVariant();
0
855}-
856-
857static QVariant parseCookieHeader(const QByteArray &raw)-
858{-
859 QList<QNetworkCookie> result;-
860 const QList<QByteArray> cookieList = raw.split(';');-
861 for (const QByteArray &cookie : cookieList) {-
862 QList<QNetworkCookie> parsed = QNetworkCookie::parseCookies(cookie.trimmed());-
863 if (parsed.count() != 1)
parsed.count() != 1Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
0-3
864 return QVariant(); // invalid Cookie: header
never executed: return QVariant();
0
865-
866 result += parsed;-
867 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_qnetworkrequest - unknown status
3
868-
869 return QVariant::fromValue(result);
executed 2 times by 1 test: return QVariant::fromValue(result);
Executed by:
  • tst_qnetworkrequest - unknown status
2
870}-
871-
872static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QByteArray &value)-
873{-
874 // header is always a valid value-
875 switch (header) {-
876 case QNetworkRequest::UserAgentHeader:
executed 9 times by 2 tests: case QNetworkRequest::UserAgentHeader:
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
9
877 case QNetworkRequest::ServerHeader:
executed 831 times by 5 tests: case QNetworkRequest::ServerHeader:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
831
878 case QNetworkRequest::ContentTypeHeader:
executed 917 times by 6 tests: case QNetworkRequest::ContentTypeHeader:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
917
879 // copy exactly, convert to QString-
880 return QString::fromLatin1(value);
executed 1757 times by 7 tests: return QString::fromLatin1(value);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1757
881-
882 case QNetworkRequest::ContentLengthHeader: {
executed 589 times by 7 tests: case QNetworkRequest::ContentLengthHeader:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
589
883 bool ok;-
884 qint64 result = value.trimmed().toLongLong(&ok);-
885 if (ok)
okDescription
TRUEevaluated 587 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
2-587
886 return result;
executed 587 times by 7 tests: return result;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
587
887 return QVariant();
executed 2 times by 1 test: return QVariant();
Executed by:
  • tst_qnetworkrequest - unknown status
2
888 }-
889-
890 case QNetworkRequest::LocationHeader: {
executed 47 times by 3 tests: case QNetworkRequest::LocationHeader:
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
47
891 QUrl result = QUrl::fromEncoded(value, QUrl::StrictMode);-
892 if (result.isValid() && !result.scheme().isEmpty())
result.isValid()Description
TRUEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
!result.scheme().isEmpty()Description
TRUEevaluated 44 times by 3 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
1-45
893 return result;
executed 44 times by 3 tests: return result;
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
44
894 return QVariant();
executed 3 times by 1 test: return QVariant();
Executed by:
  • tst_qnetworkrequest - unknown status
3
895 }-
896-
897 case QNetworkRequest::LastModifiedHeader:
executed 313 times by 5 tests: case QNetworkRequest::LastModifiedHeader:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
313
898 return parseHttpDate(value);
executed 313 times by 5 tests: return parseHttpDate(value);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
313
899-
900 case QNetworkRequest::CookieHeader:
executed 2 times by 1 test: case QNetworkRequest::CookieHeader:
Executed by:
  • tst_qnetworkrequest - unknown status
2
901 return parseCookieHeader(value);
executed 2 times by 1 test: return parseCookieHeader(value);
Executed by:
  • tst_qnetworkrequest - unknown status
2
902-
903 case QNetworkRequest::SetCookieHeader:
executed 19 times by 3 tests: case QNetworkRequest::SetCookieHeader:
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
19
904 return QVariant::fromValue(QNetworkCookie::parseCookies(value));
executed 19 times by 3 tests: return QVariant::fromValue(QNetworkCookie::parseCookies(value));
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
19
905-
906 default:
never executed: default:
0
907 Q_ASSERT(0);-
908 }
never executed: end of block
0
909 return QVariant();
never executed: return QVariant();
0
910}-
911-
912QNetworkHeadersPrivate::RawHeadersList::ConstIterator-
913QNetworkHeadersPrivate::findRawHeader(const QByteArray &key) const-
914{-
915 RawHeadersList::ConstIterator it = rawHeaders.constBegin();-
916 RawHeadersList::ConstIterator end = rawHeaders.constEnd();-
917 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 20068 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 6784 times by 13 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qhttpsocketengine - unknown status
  • tst_qnetworkrequest - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
6784-20068
918 if (qstricmp(it->first.constData(), key.constData()) == 0)
qstricmp(it->f...stData()) == 0Description
TRUEevaluated 1002 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 19066 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1002-19066
919 return it;
executed 1002 times by 7 tests: return it;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1002
920-
921 return end; // not found
executed 6784 times by 13 tests: return end;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qhttpsocketengine - unknown status
  • tst_qnetworkrequest - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
6784
922}-
923-
924QNetworkHeadersPrivate::RawHeadersList QNetworkHeadersPrivate::allRawHeaders() const-
925{-
926 return rawHeaders;
executed 26 times by 2 tests: return rawHeaders;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
26
927}-
928-
929QList<QByteArray> QNetworkHeadersPrivate::rawHeadersKeys() const-
930{-
931 QList<QByteArray> result;-
932 result.reserve(rawHeaders.size());-
933 RawHeadersList::ConstIterator it = rawHeaders.constBegin(),-
934 end = rawHeaders.constEnd();-
935 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 1079 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 1533 times by 14 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qhttpsocketengine - unknown status
  • tst_qnetworkrequest - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
1079-1533
936 result << it->first;
executed 1079 times by 6 tests: result << it->first;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1079
937-
938 return result;
executed 1533 times by 14 tests: return result;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qhttpsocketengine - unknown status
  • tst_qnetworkrequest - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
1533
939}-
940-
941void QNetworkHeadersPrivate::setRawHeader(const QByteArray &key, const QByteArray &value)-
942{-
943 if (key.isEmpty())
key.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
FALSEevaluated 5698 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
2-5698
944 // refuse to accept an empty raw header-
945 return;
executed 2 times by 1 test: return;
Executed by:
  • tst_qnetworkrequest - unknown status
2
946-
947 setRawHeaderInternal(key, value);-
948 parseAndSetHeader(key, value);-
949}
executed 5698 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
5698
950-
951/*!-
952 \internal-
953 Sets the internal raw headers list to match \a list. The cooked headers-
954 will also be updated.-
955-
956 If \a list contains duplicates, they will be stored, but only the first one-
957 is usually accessed.-
958*/-
959void QNetworkHeadersPrivate::setAllRawHeaders(const RawHeadersList &list)-
960{-
961 cookedHeaders.clear();-
962 rawHeaders = list;-
963-
964 RawHeadersList::ConstIterator it = rawHeaders.constBegin();-
965 RawHeadersList::ConstIterator end = rawHeaders.constEnd();-
966 for ( ; it != end; ++it)
it != endDescription
TRUEevaluated 164 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 107 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
107-164
967 parseAndSetHeader(it->first, it->second);
executed 164 times by 3 tests: parseAndSetHeader(it->first, it->second);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
164
968}
executed 107 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
107
969-
970void QNetworkHeadersPrivate::setCookedHeader(QNetworkRequest::KnownHeaders header,-
971 const QVariant &value)-
972{-
973 QByteArray name = headerName(header);-
974 if (name.isEmpty()) {
name.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 459 times by 5 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
0-459
975 // headerName verifies that \a header is a known value-
976 qWarning("QNetworkRequest::setHeader: invalid header value KnownHeader(%d) received", header);-
977 return;
never executed: return;
0
978 }-
979-
980 if (value.isNull()) {
value.isNull()Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 455 times by 5 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
4-455
981 setRawHeaderInternal(name, QByteArray());-
982 cookedHeaders.remove(header);-
983 } else {
executed 4 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
4
984 QByteArray rawValue = headerValue(header, value);-
985 if (rawValue.isEmpty()) {
rawValue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 455 times by 5 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
0-455
986 qWarning("QNetworkRequest::setHeader: QVariant of type %s cannot be used with header %s",-
987 value.typeName(), name.constData());-
988 return;
never executed: return;
0
989 }-
990-
991 setRawHeaderInternal(name, rawValue);-
992 cookedHeaders.insert(header, value);-
993 }
executed 455 times by 5 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
455
994}-
995-
996void QNetworkHeadersPrivate::setRawHeaderInternal(const QByteArray &key, const QByteArray &value)-
997{-
998 auto firstEqualsKey = [&key](const RawHeaderPair &header) {-
999 return qstricmp(header.first.constData(), key.constData()) == 0;
executed 17730 times by 9 tests: return qstricmp(header.first.constData(), key.constData()) == 0;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
17730
1000 };-
1001 rawHeaders.erase(std::remove_if(rawHeaders.begin(), rawHeaders.end(),-
1002 firstEqualsKey),-
1003 rawHeaders.end());-
1004-
1005 if (value.isNull())
value.isNull()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
FALSEevaluated 6148 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
9-6148
1006 return; // only wanted to erase key
executed 9 times by 2 tests: return;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
9
1007-
1008 RawHeaderPair pair;-
1009 pair.first = key;-
1010 pair.second = value;-
1011 rawHeaders.append(pair);-
1012}
executed 6148 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
6148
1013-
1014void QNetworkHeadersPrivate::parseAndSetHeader(const QByteArray &key, const QByteArray &value)-
1015{-
1016 // is it a known header?-
1017 const int parsedKeyAsInt = parseHeaderName(key);-
1018 if (parsedKeyAsInt != -1) {
parsedKeyAsInt != -1Description
TRUEevaluated 2728 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 3134 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
2728-3134
1019 const QNetworkRequest::KnownHeaders parsedKey-
1020 = static_cast<QNetworkRequest::KnownHeaders>(parsedKeyAsInt);-
1021 if (value.isNull()) {
value.isNull()Description
TRUEnever evaluated
FALSEevaluated 2728 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
0-2728
1022 cookedHeaders.remove(parsedKey);-
1023 } else if (parsedKey == QNetworkRequest::ContentLengthHeader
never executed: end of block
parsedKey == Q...ntLengthHeaderDescription
TRUEevaluated 590 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 2138 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
0-2138
1024 && cookedHeaders.contains(QNetworkRequest::ContentLengthHeader)) {
cookedHeaders....tLengthHeader)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 589 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1-589
1025 // Only set the cooked header "Content-Length" once.-
1026 // See bug QTBUG-15311-
1027 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
1028 cookedHeaders.insert(parsedKey, parseHeaderValue(parsedKey, value));-
1029 }
executed 2727 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
2727
1030-
1031 }-
1032}
executed 5862 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
5862
1033-
1034// Fast month string to int conversion. This code-
1035// assumes that the Month name is correct and that-
1036// the string is at least three chars long.-
1037static int name_to_month(const char* month_str)-
1038{-
1039 switch (month_str[0]) {-
1040 case 'J':
executed 20 times by 1 test: case 'J':
Executed by:
  • tst_QAbstractNetworkCache
20
1041 switch (month_str[1]) {-
1042 case 'a':
executed 20 times by 1 test: case 'a':
Executed by:
  • tst_QAbstractNetworkCache
20
1043 return 1;
executed 20 times by 1 test: return 1;
Executed by:
  • tst_QAbstractNetworkCache
20
1044 case 'u':
never executed: case 'u':
0
1045 switch (month_str[2] ) {-
1046 case 'n':
never executed: case 'n':
0
1047 return 6;
never executed: return 6;
0
1048 case 'l':
never executed: case 'l':
0
1049 return 7;
never executed: return 7;
0
1050 }-
1051 }
never executed: end of block
0
1052 break;
never executed: break;
0
1053 case 'F':
never executed: case 'F':
0
1054 return 2;
never executed: return 2;
0
1055 case 'M':
executed 78 times by 2 tests: case 'M':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
78
1056 switch (month_str[2] ) {-
1057 case 'r':
executed 1 time by 1 test: case 'r':
Executed by:
  • tst_QNetworkReply
1
1058 return 3;
executed 1 time by 1 test: return 3;
Executed by:
  • tst_QNetworkReply
1
1059 case 'y':
executed 77 times by 2 tests: case 'y':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
77
1060 return 5;
executed 77 times by 2 tests: return 5;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
77
1061 }-
1062 break;
never executed: break;
0
1063 case 'A':
never executed: case 'A':
0
1064 switch (month_str[1]) {-
1065 case 'p':
never executed: case 'p':
0
1066 return 4;
never executed: return 4;
0
1067 case 'u':
never executed: case 'u':
0
1068 return 8;
never executed: return 8;
0
1069 }-
1070 break;
never executed: break;
0
1071 case 'O':
executed 225 times by 4 tests: case 'O':
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
225
1072 return 10;
executed 225 times by 4 tests: return 10;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
225
1073 case 'S':
never executed: case 'S':
0
1074 return 9;
never executed: return 9;
0
1075 case 'N':
executed 42 times by 3 tests: case 'N':
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
42
1076 return 11;
executed 42 times by 3 tests: return 11;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
42
1077 case 'D':
never executed: case 'D':
0
1078 return 12;
never executed: return 12;
0
1079 }-
1080-
1081 return 0;
never executed: return 0;
0
1082}-
1083-
1084QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value)-
1085{-
1086 // HTTP dates have three possible formats:-
1087 // RFC 1123/822 - ddd, dd MMM yyyy hh:mm:ss "GMT"-
1088 // RFC 850 - dddd, dd-MMM-yy hh:mm:ss "GMT"-
1089 // ANSI C's asctime - ddd MMM d hh:mm:ss yyyy-
1090 // We only handle them exactly. If they deviate, we bail out.-
1091-
1092 int pos = value.indexOf(',');-
1093 QDateTime dt;-
1094#ifndef QT_NO_DATESTRING-
1095 if (pos == -1) {
pos == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
FALSEevaluated 366 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
1-366
1096 // no comma -> asctime(3) format-
1097 dt = QDateTime::fromString(QString::fromLatin1(value), Qt::TextDate);-
1098 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qnetworkrequest - unknown status
1
1099 // Use sscanf over QLocal/QDateTimeParser for speed reasons. See the-
1100 // Qt WebKit performance benchmarks to get an idea.-
1101 if (pos == 3) {
pos == 3Description
TRUEevaluated 365 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkrequest - unknown status
1-365
1102 char month_name[4];-
1103 int day, year, hour, minute, second;-
1104#ifdef Q_CC_MSVC-
1105 // Use secure version to avoid compiler warning-
1106 if (sscanf_s(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, 4, &year, &hour, &minute, &second) == 6)-
1107#else-
1108 // The POSIX secure mode is %ms (which allocates memory), too bleeding edge for now-
1109 // In any case this is already safe as field width is specified.-
1110 if (sscanf(value.constData(), "%*3s, %d %3s %d %d:%d:%d 'GMT'", &day, month_name, &year, &hour, &minute, &second) == 6)
sscanf(value.c... &second) == 6Description
TRUEevaluated 365 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEnever evaluated
0-365
1111#endif-
1112 dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second));
executed 365 times by 5 tests: dt = QDateTime(QDate(year, name_to_month(month_name), day), QTime(hour, minute, second));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
365
1113 } else {
executed 365 times by 5 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
365
1114 QLocale c = QLocale::c();-
1115 // eat the weekday, the comma and the space following it-
1116 QString sansWeekday = QString::fromLatin1(value.constData() + pos + 2);-
1117 // must be RFC 850 date-
1118 dt = c.toDateTime(sansWeekday, QLatin1String("dd-MMM-yy hh:mm:ss 'GMT'"));-
1119 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_qnetworkrequest - unknown status
1
1120 }-
1121#endif // QT_NO_DATESTRING-
1122-
1123 if (dt.isValid())
dt.isValid()Description
TRUEevaluated 367 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
FALSEnever evaluated
0-367
1124 dt.setTimeSpec(Qt::UTC);
executed 367 times by 5 tests: dt.setTimeSpec(Qt::UTC);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
367
1125 return dt;
executed 367 times by 5 tests: return dt;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
  • tst_qnetworkrequest - unknown status
367
1126}-
1127-
1128QByteArray QNetworkHeadersPrivate::toHttpDate(const QDateTime &dt)-
1129{-
1130 return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'"))
executed 79 times by 4 tests: return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'")) .toLatin1();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
79
1131 .toLatin1();
executed 79 times by 4 tests: return QLocale::c().toString(dt, QLatin1String("ddd, dd MMM yyyy hh:mm:ss 'GMT'")) .toLatin1();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_qnetworkrequest - unknown status
79
1132}-
1133-
1134QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9