qnetworkreply.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkreply.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qnetworkreply.h"-
35#include "qnetworkreply_p.h"-
36#include <QtNetwork/qsslconfiguration.h>-
37-
38QT_BEGIN_NAMESPACE-
39-
40const int QNetworkReplyPrivate::progressSignalInterval = 100;-
41-
42QNetworkReplyPrivate::QNetworkReplyPrivate()-
43 : readBufferMaxSize(0),-
44 emitAllUploadProgressSignals(false),-
45 operation(QNetworkAccessManager::UnknownOperation),-
46 errorCode(QNetworkReply::NoError)-
47 , isFinished(false)-
48{-
49 // set the default attribute values-
50 attributes.insert(QNetworkRequest::ConnectionEncryptedAttribute, false);-
51}
executed 1069 times by 10 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
1069
52-
53-
54/*!-
55 \class QNetworkReply-
56 \since 4.4-
57 \brief The QNetworkReply class contains the data and headers for a request-
58 sent with QNetworkAccessManager-
59-
60 \reentrant-
61 \ingroup network-
62 \inmodule QtNetwork-
63-
64 The QNetworkReply class contains the data and meta data related to-
65 a request posted with QNetworkAccessManager. Like QNetworkRequest,-
66 it contains a URL and headers (both in parsed and raw form), some-
67 information about the reply's state and the contents of the reply-
68 itself.-
69-
70 QNetworkReply is a sequential-access QIODevice, which means that-
71 once data is read from the object, it no longer kept by the-
72 device. It is therefore the application's responsibility to keep-
73 this data if it needs to. Whenever more data is received from the-
74 network and processed, the readyRead() signal is emitted.-
75-
76 The downloadProgress() signal is also emitted when data is-
77 received, but the number of bytes contained in it may not-
78 represent the actual bytes received, if any transformation is done-
79 to the contents (for example, decompressing and removing the-
80 protocol overhead).-
81-
82 Even though QNetworkReply is a QIODevice connected to the contents-
83 of the reply, it also emits the uploadProgress() signal, which-
84 indicates the progress of the upload for operations that have such-
85 content.-
86-
87 \note Do not delete the object in the slot connected to the-
88 error() or finished() signal. Use deleteLater().-
89-
90 \sa QNetworkRequest, QNetworkAccessManager-
91*/-
92-
93/*!-
94 \enum QNetworkReply::NetworkError-
95-
96 Indicates all possible error conditions found during the-
97 processing of the request.-
98-
99 \value NoError no error condition.-
100 \note When the HTTP protocol returns a redirect no error will be-
101 reported. You can check if there is a redirect with the-
102 QNetworkRequest::RedirectionTargetAttribute attribute.-
103-
104 \value ConnectionRefusedError the remote server refused the-
105 connection (the server is not accepting requests)-
106-
107 \value RemoteHostClosedError the remote server closed the-
108 connection prematurely, before the entire reply was received and-
109 processed-
110-
111 \value HostNotFoundError the remote host name was not found-
112 (invalid hostname)-
113-
114 \value TimeoutError the connection to the remote server-
115 timed out-
116-
117 \value OperationCanceledError the operation was canceled via calls-
118 to abort() or close() before it was finished.-
119-
120 \value SslHandshakeFailedError the SSL/TLS handshake failed and the-
121 encrypted channel could not be established. The sslErrors() signal-
122 should have been emitted.-
123-
124 \value TemporaryNetworkFailureError the connection was broken due-
125 to disconnection from the network, however the system has initiated-
126 roaming to another access point. The request should be resubmitted-
127 and will be processed as soon as the connection is re-established.-
128-
129 \value NetworkSessionFailedError the connection was broken due-
130 to disconnection from the network or failure to start the network.-
131-
132 \value BackgroundRequestNotAllowedError the background request-
133 is not currently allowed due to platform policy.-
134-
135 \value TooManyRedirectsError while following redirects, the maximum-
136 limit was reached. The limit is by default set to 50 or as set by-
137 QNetworkRequest::setMaxRedirectsAllowed().-
138 (This value was introduced in 5.6.)-
139-
140 \value InsecureRedirectError while following redirects, the network-
141 access API detected a redirect from a encrypted protocol (https) to an-
142 unencrypted one (http).-
143 (This value was introduced in 5.6.)-
144-
145 \value ProxyConnectionRefusedError the connection to the proxy-
146 server was refused (the proxy server is not accepting requests)-
147-
148 \value ProxyConnectionClosedError the proxy server closed the-
149 connection prematurely, before the entire reply was received and-
150 processed-
151-
152 \value ProxyNotFoundError the proxy host name was not-
153 found (invalid proxy hostname)-
154-
155 \value ProxyTimeoutError the connection to the proxy-
156 timed out or the proxy did not reply in time to the request sent-
157-
158 \value ProxyAuthenticationRequiredError the proxy requires-
159 authentication in order to honour the request but did not accept-
160 any credentials offered (if any)-
161-
162 \value ContentAccessDenied the access to the remote-
163 content was denied (similar to HTTP error 401)-
164-
165 \value ContentOperationNotPermittedError the operation requested-
166 on the remote content is not permitted-
167-
168 \value ContentNotFoundError the remote content was not-
169 found at the server (similar to HTTP error 404)-
170-
171 \value AuthenticationRequiredError the remote server requires-
172 authentication to serve the content but the credentials provided-
173 were not accepted (if any)-
174-
175 \value ContentReSendError the request needed to be sent-
176 again, but this failed for example because the upload data-
177 could not be read a second time.-
178-
179 \value ContentConflictError the request could not be completed due-
180 to a conflict with the current state of the resource.-
181-
182 \value ContentGoneError the requested resource is no longer-
183 available at the server.-
184-
185 \value InternalServerError the server encountered an unexpected-
186 condition which prevented it from fulfilling the request.-
187-
188 \value OperationNotImplementedError the server does not support the-
189 functionality required to fulfill the request.-
190-
191 \value ServiceUnavailableError the server is unable to handle the-
192 request at this time.-
193-
194 \value ProtocolUnknownError the Network Access API cannot-
195 honor the request because the protocol is not known-
196-
197 \value ProtocolInvalidOperationError the requested operation is-
198 invalid for this protocol-
199-
200 \value UnknownNetworkError an unknown network-related-
201 error was detected-
202-
203 \value UnknownProxyError an unknown proxy-related error-
204 was detected-
205-
206 \value UnknownContentError an unknown error related to-
207 the remote content was detected-
208-
209 \value ProtocolFailure a breakdown in protocol was-
210 detected (parsing error, invalid or unexpected responses, etc.)-
211-
212 \value UnknownServerError an unknown error related to-
213 the server response was detected-
214-
215 \sa error()-
216*/-
217-
218/*!-
219 \fn void QNetworkReply::encrypted()-
220 \since 5.1-
221-
222 This signal is emitted when an SSL/TLS session has successfully-
223 completed the initial handshake. At this point, no user data-
224 has been transmitted. The signal can be used to perform-
225 additional checks on the certificate chain, for example to-
226 notify users when the certificate for a website has changed.-
227 If the reply does not match the expected criteria then it should-
228 be aborted by calling QNetworkReply::abort() by a slot connected-
229 to this signal. The SSL configuration in use can be inspected-
230 using the QNetworkReply::sslConfiguration() method.-
231-
232 Internally, QNetworkAccessManager may open multiple connections-
233 to a server, in order to allow it process requests in parallel.-
234 These connections may be reused, which means that the encrypted()-
235 signal would not be emitted. This means that you are only-
236 guaranteed to receive this signal for the first connection to a-
237 site in the lifespan of the QNetworkAccessManager.-
238-
239 \sa QSslSocket::encrypted()-
240 \sa QNetworkAccessManager::encrypted()-
241*/-
242-
243/*!-
244 \fn void QNetworkReply::sslErrors(const QList<QSslError> &errors)-
245-
246 This signal is emitted if the SSL/TLS session encountered errors-
247 during the set up, including certificate verification errors. The-
248 \a errors parameter contains the list of errors.-
249-
250 To indicate that the errors are not fatal and that the connection-
251 should proceed, the ignoreSslErrors() function should be called-
252 from the slot connected to this signal. If it is not called, the-
253 SSL session will be torn down before any data is exchanged-
254 (including the URL).-
255-
256 This signal can be used to display an error message to the user-
257 indicating that security may be compromised and display the-
258 SSL settings (see sslConfiguration() to obtain it). If the user-
259 decides to proceed after analyzing the remote certificate, the-
260 slot should call ignoreSslErrors().-
261-
262 \sa QSslSocket::sslErrors(), QNetworkAccessManager::sslErrors(),-
263 sslConfiguration(), ignoreSslErrors()-
264*/-
265-
266/*!-
267 \fn void QNetworkReply::preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)-
268 \since 5.5-
269-
270 This signal is emitted if the SSL/TLS handshake negotiates a PSK-
271 ciphersuite, and therefore a PSK authentication is then required.-
272-
273 When using PSK, the client must send to the server a valid identity and a-
274 valid pre shared key, in order for the SSL handshake to continue.-
275 Applications can provide this information in a slot connected to this-
276 signal, by filling in the passed \a authenticator object according to their-
277 needs.-
278-
279 \note Ignoring this signal, or failing to provide the required credentials,-
280 will cause the handshake to fail, and therefore the connection to be aborted.-
281-
282 \note The \a authenticator object is owned by the reply and must not be-
283 deleted by the application.-
284-
285 \sa QSslPreSharedKeyAuthenticator-
286*/-
287-
288/*!-
289 \fn void QNetworkReply::redirected(const QUrl &url)-
290 \since 5.6-
291-
292 This signal is emitted if the QNetworkRequest::FollowRedirectsAttribute was-
293 set in the request and the server responded with a 3xx status (specifically-
294 301, 302, 303, 305 or 307 status code) with a valid url in the location-
295 header, indicating a HTTP redirect. The \a url parameter contains the new-
296 redirect url as returned by the server in the location header.-
297-
298 \sa QNetworkRequest::FollowRedirectsAttribute-
299*/-
300-
301/*!-
302 \fn void QNetworkReply::metaDataChanged()-
303-
304 \omit FIXME: Update name? \endomit-
305-
306 This signal is emitted whenever the metadata in this reply-
307 changes. metadata is any information that is not the content-
308 (data) itself, including the network headers. In the majority of-
309 cases, the metadata will be known fully by the time the first-
310 byte of data is received. However, it is possible to receive-
311 updates of headers or other metadata during the processing of the-
312 data.-
313-
314 \sa header(), rawHeaderList(), rawHeader(), hasRawHeader()-
315*/-
316-
317/*!-
318 \fn void QNetworkReply::finished()-
319-
320 This signal is emitted when the reply has finished-
321 processing. After this signal is emitted, there will be no more-
322 updates to the reply's data or metadata.-
323-
324 Unless close() or abort() have been called, the reply will be still be opened-
325 for reading, so the data can be retrieved by calls to read() or-
326 readAll(). In particular, if no calls to read() were made as a-
327 result of readyRead(), a call to readAll() will retrieve the full-
328 contents in a QByteArray.-
329-
330 This signal is emitted in tandem with-
331 QNetworkAccessManager::finished() where that signal's reply-
332 parameter is this object.-
333-
334 \note Do not delete the object in the slot connected to this-
335 signal. Use deleteLater().-
336-
337 You can also use isFinished() to check if a QNetworkReply-
338 has finished even before you receive the finished() signal.-
339-
340 \sa QNetworkAccessManager::finished(), isFinished()-
341*/-
342-
343/*!-
344 \fn void QNetworkReply::error(QNetworkReply::NetworkError code)-
345-
346 This signal is emitted when the reply detects an error in-
347 processing. The finished() signal will probably follow, indicating-
348 that the connection is over.-
349-
350 The \a code parameter contains the code of the error that was-
351 detected. Call errorString() to obtain a textual representation of-
352 the error condition.-
353-
354 \note Do not delete the object in the slot connected to this-
355 signal. Use deleteLater().-
356-
357 \sa error(), errorString()-
358*/-
359-
360/*!-
361 \fn void QNetworkReply::uploadProgress(qint64 bytesSent, qint64 bytesTotal)-
362-
363 This signal is emitted to indicate the progress of the upload part-
364 of this network request, if there's any. If there's no upload-
365 associated with this request, this signal will not be emitted.-
366-
367 The \a bytesSent-
368 parameter indicates the number of bytes uploaded, while \a-
369 bytesTotal indicates the total number of bytes to be uploaded. If-
370 the number of bytes to be uploaded could not be determined, \a-
371 bytesTotal will be -1.-
372-
373 The upload is finished when \a bytesSent is equal to \a-
374 bytesTotal. At that time, \a bytesTotal will not be -1.-
375-
376 \sa downloadProgress()-
377*/-
378-
379/*!-
380 \fn void QNetworkReply::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)-
381-
382 This signal is emitted to indicate the progress of the download-
383 part of this network request, if there's any. If there's no-
384 download associated with this request, this signal will be emitted-
385 once with 0 as the value of both \a bytesReceived and \a-
386 bytesTotal.-
387-
388 The \a bytesReceived parameter indicates the number of bytes-
389 received, while \a bytesTotal indicates the total number of bytes-
390 expected to be downloaded. If the number of bytes to be downloaded-
391 is not known, \a bytesTotal will be -1.-
392-
393 The download is finished when \a bytesReceived is equal to \a-
394 bytesTotal. At that time, \a bytesTotal will not be -1.-
395-
396 Note that the values of both \a bytesReceived and \a bytesTotal-
397 may be different from size(), the total number of bytes-
398 obtained through read() or readAll(), or the value of the-
399 header(ContentLengthHeader). The reason for that is that there may-
400 be protocol overhead or the data may be compressed during the-
401 download.-
402-
403 \sa uploadProgress(), bytesAvailable()-
404*/-
405-
406/*!-
407 \fn void QNetworkReply::abort()-
408-
409 Aborts the operation immediately and close down any network-
410 connections still open. Uploads still in progress are also-
411 aborted.-
412-
413 The finished() signal will also be emitted.-
414-
415 \sa close(), finished()-
416*/-
417-
418/*!-
419 Creates a QNetworkReply object with parent \a parent.-
420-
421 You cannot directly instantiate QNetworkReply objects. Use-
422 QNetworkAccessManager functions to do that.-
423*/-
424QNetworkReply::QNetworkReply(QObject *parent)-
425 : QIODevice(*new QNetworkReplyPrivate, parent)-
426{-
427}
never executed: end of block
0
428-
429/*!-
430 \internal-
431*/-
432QNetworkReply::QNetworkReply(QNetworkReplyPrivate &dd, QObject *parent)-
433 : QIODevice(dd, parent)-
434{-
435}
executed 1069 times by 10 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
1069
436-
437/*!-
438 Disposes of this reply and frees any resources associated with-
439 it. If any network connections are still open, they will be-
440 closed.-
441-
442 \sa abort(), close()-
443*/-
444QNetworkReply::~QNetworkReply()-
445{-
446}-
447-
448/*!-
449 Closes this device for reading. Unread data is discarded, but the-
450 network resources are not discarded until they are finished. In-
451 particular, if any upload is in progress, it will continue until-
452 it is done.-
453-
454 The finished() signal is emitted when all operations are over and-
455 the network resources are freed.-
456-
457 \sa abort(), finished()-
458*/-
459void QNetworkReply::close()-
460{-
461 QIODevice::close();-
462}
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
6
463-
464/*!-
465 \internal-
466*/-
467bool QNetworkReply::isSequential() const-
468{-
469 return true;
executed 94 times by 2 tests: return true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
94
470}-
471-
472/*!-
473 Returns the size of the read buffer, in bytes.-
474-
475 \sa setReadBufferSize()-
476*/-
477qint64 QNetworkReply::readBufferSize() const-
478{-
479 return d_func()->readBufferMaxSize;
executed 550 times by 3 tests: return d_func()->readBufferMaxSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
550
480}-
481-
482/*!-
483 Sets the size of the read buffer to be \a size bytes. The read-
484 buffer is the buffer that holds data that is being downloaded off-
485 the network, before it is read with QIODevice::read(). Setting the-
486 buffer size to 0 will make the buffer unlimited in size.-
487-
488 QNetworkReply will try to stop reading from the network once this-
489 buffer is full (i.e., bytesAvailable() returns \a size or more),-
490 thus causing the download to throttle down as well. If the buffer-
491 is not limited in size, QNetworkReply will try to download as fast-
492 as possible from the network.-
493-
494 Unlike QAbstractSocket::setReadBufferSize(), QNetworkReply cannot-
495 guarantee precision in the read buffer size. That is,-
496 bytesAvailable() can return more than \a size.-
497-
498 \sa readBufferSize()-
499*/-
500void QNetworkReply::setReadBufferSize(qint64 size)-
501{-
502 Q_D(QNetworkReply);-
503 d->readBufferMaxSize = size;-
504}
executed 23 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
23
505-
506/*!-
507 Returns the QNetworkAccessManager that was used to create this-
508 QNetworkReply object. Initially, it is also the parent object.-
509*/-
510QNetworkAccessManager *QNetworkReply::manager() const-
511{-
512 return d_func()->manager;
executed 1 time by 1 test: return d_func()->manager;
Executed by:
  • tst_QNetworkReply
1
513}-
514-
515/*!-
516 Returns the request that was posted for this reply. In special,-
517 note that the URL for the request may be different than that of-
518 the reply.-
519-
520 \sa QNetworkRequest::url(), url(), setRequest()-
521*/-
522QNetworkRequest QNetworkReply::request() const-
523{-
524 return d_func()->originalRequest;
executed 3 times by 1 test: return d_func()->originalRequest;
Executed by:
  • tst_QNetworkReply
3
525}-
526-
527/*!-
528 Returns the operation that was posted for this reply.-
529-
530 \sa setOperation()-
531*/-
532QNetworkAccessManager::Operation QNetworkReply::operation() const-
533{-
534 return d_func()->operation;
executed 1 time by 1 test: return d_func()->operation;
Executed by:
  • tst_QNetworkReply
1
535}-
536-
537/*!-
538 Returns the error that was found during the processing of this-
539 request. If no error was found, returns NoError.-
540-
541 \sa setError()-
542*/-
543QNetworkReply::NetworkError QNetworkReply::error() const-
544{-
545 return d_func()->errorCode;
executed 1285 times by 3 tests: return d_func()->errorCode;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
  • tst_Spdy
1285
546}-
547-
548/*!-
549 \since 4.6-
550-
551 Returns \c true when the reply has finished or was aborted.-
552-
553 \sa isRunning()-
554*/-
555bool QNetworkReply::isFinished() const-
556{-
557 return d_func()->isFinished;
executed 2517 times by 1 test: return d_func()->isFinished;
Executed by:
  • tst_QNetworkReply
2517
558}-
559-
560/*!-
561 \since 4.6-
562-
563 Returns \c true when the request is still processing and the-
564 reply has not finished or was aborted yet.-
565-
566 \sa isFinished()-
567*/-
568bool QNetworkReply::isRunning() const-
569{-
570 return !isFinished();
executed 16 times by 1 test: return !isFinished();
Executed by:
  • tst_QNetworkReply
16
571}-
572-
573/*!-
574 Returns the URL of the content downloaded or uploaded. Note that-
575 the URL may be different from that of the original request. If the-
576 QNetworkRequest::FollowRedirectsAttribute was set in the request, then this-
577 function returns the current url that the network API is accessing, i.e the-
578 url emitted in the QNetworkReply::redirected signal.-
579-
580 \sa request(), setUrl(), QNetworkRequest::url(), redirected()-
581*/-
582QUrl QNetworkReply::url() const-
583{-
584 return d_func()->url;
executed 708 times by 2 tests: return d_func()->url;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
708
585}-
586-
587/*!-
588 Returns the value of the known header \a header, if that header-
589 was sent by the remote server. If the header was not sent, returns-
590 an invalid QVariant.-
591-
592 \sa rawHeader(), setHeader(), QNetworkRequest::header()-
593*/-
594QVariant QNetworkReply::header(QNetworkRequest::KnownHeaders header) const-
595{-
596 return d_func()->cookedHeaders.value(header);
executed 347 times by 2 tests: return d_func()->cookedHeaders.value(header);
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
347
597}-
598-
599/*!-
600 Returns \c true if the raw header of name \a headerName was sent by-
601 the remote server-
602-
603 \sa rawHeader()-
604*/-
605bool QNetworkReply::hasRawHeader(const QByteArray &headerName) const-
606{-
607 Q_D(const QNetworkReply);-
608 return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
never executed: return d->findRawHeader(headerName) != d->rawHeaders.constEnd();
0
609}-
610-
611/*!-
612 Returns the raw contents of the header \a headerName as sent by-
613 the remote server. If there is no such header, returns an empty-
614 byte array, which may be indistinguishable from an empty-
615 header. Use hasRawHeader() to verify if the server sent such-
616 header field.-
617-
618 \sa setRawHeader(), hasRawHeader(), header()-
619*/-
620QByteArray QNetworkReply::rawHeader(const QByteArray &headerName) const-
621{-
622 Q_D(const QNetworkReply);-
623 QNetworkHeadersPrivate::RawHeadersList::ConstIterator it =-
624 d->findRawHeader(headerName);-
625 if (it != d->rawHeaders.constEnd())
it != d->rawHeaders.constEnd()Description
TRUEevaluated 409 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 5044 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
409-5044
626 return it->second;
executed 409 times by 5 tests: return it->second;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
409
627 return QByteArray();
executed 5044 times by 6 tests: return QByteArray();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
5044
628}-
629-
630/*! \typedef QNetworkReply::RawHeaderPair-
631-
632 RawHeaderPair is a QPair<QByteArray, QByteArray> where the first-
633 QByteArray is the header name and the second is the header.-
634 */-
635-
636/*!-
637 Returns a list of raw header pairs.-
638 */-
639const QList<QNetworkReply::RawHeaderPair>& QNetworkReply::rawHeaderPairs() const-
640{-
641 Q_D(const QNetworkReply);-
642 return d->rawHeaders;
never executed: return d->rawHeaders;
0
643}-
644-
645/*!-
646 Returns a list of headers fields that were sent by the remote-
647 server, in the order that they were sent. Duplicate headers are-
648 merged together and take place of the latter duplicate.-
649*/-
650QList<QByteArray> QNetworkReply::rawHeaderList() const-
651{-
652 return d_func()->rawHeadersKeys();
executed 116 times by 3 tests: return d_func()->rawHeadersKeys();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
116
653}-
654-
655/*!-
656 Returns the attribute associated with the code \a code. If the-
657 attribute has not been set, it returns an invalid QVariant (type QMetaType::UnknownType).-
658-
659 You can expect the default values listed in-
660 QNetworkRequest::Attribute to be applied to the values returned by-
661 this function.-
662-
663 \sa setAttribute(), QNetworkRequest::Attribute-
664*/-
665QVariant QNetworkReply::attribute(QNetworkRequest::Attribute code) const-
666{-
667 return d_func()->attributes.value(code);
executed 829 times by 4 tests: return d_func()->attributes.value(code);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
829
668}-
669-
670#ifndef QT_NO_SSL-
671/*!-
672 Returns the SSL configuration and state associated with this-
673 reply, if SSL was used. It will contain the remote server's-
674 certificate, its certificate chain leading to the Certificate-
675 Authority as well as the encryption ciphers in use.-
676-
677 The peer's certificate and its certificate chain will be known by-
678 the time sslErrors() is emitted, if it's emitted.-
679*/-
680QSslConfiguration QNetworkReply::sslConfiguration() const-
681{-
682 QSslConfiguration config;-
683 sslConfigurationImplementation(config);-
684 return config;
executed 211 times by 2 tests: return config;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
211
685}-
686-
687/*!-
688 Sets the SSL configuration for the network connection associated-
689 with this request, if possible, to be that of \a config.-
690*/-
691void QNetworkReply::setSslConfiguration(const QSslConfiguration &config)-
692{-
693 setSslConfigurationImplementation(config);-
694}
executed 108 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
108
695-
696/*!-
697 \overload-
698 \since 4.6-
699-
700 If this function is called, the SSL errors given in \a errors-
701 will be ignored.-
702-
703 \note Because most SSL errors are associated with a certificate, for most-
704 of them you must set the expected certificate this SSL error is related to.-
705 If, for instance, you want to issue a request to a server that uses-
706 a self-signed certificate, consider the following snippet:-
707-
708 \snippet code/src_network_access_qnetworkreply.cpp 0-
709-
710 Multiple calls to this function will replace the list of errors that-
711 were passed in previous calls.-
712 You can clear the list of errors you want to ignore by calling this-
713 function with an empty list.-
714-
715 \sa sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()-
716*/-
717void QNetworkReply::ignoreSslErrors(const QList<QSslError> &errors)-
718{-
719 ignoreSslErrorsImplementation(errors);-
720}
executed 10 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
10
721#endif-
722-
723/*!-
724 \fn void QNetworkReply::sslConfigurationImplementation(QSslConfiguration &configuration) const-
725 \since 5.0-
726-
727 This virtual method is provided to enable overriding the behavior of-
728 sslConfiguration(). sslConfiguration() is a public wrapper for this method.-
729 The configuration will be returned in \a configuration.-
730-
731 \sa sslConfiguration()-
732*/-
733void QNetworkReply::sslConfigurationImplementation(QSslConfiguration &) const-
734{-
735}-
736-
737/*!-
738 \fn void QNetworkReply::setSslConfigurationImplementation(const QSslConfiguration &configuration)-
739 \since 5.0-
740-
741 This virtual method is provided to enable overriding the behavior of-
742 setSslConfiguration(). setSslConfiguration() is a public wrapper for this method.-
743 If you override this method use \a configuration to set the SSL configuration.-
744-
745 \sa sslConfigurationImplementation(), setSslConfiguration()-
746*/-
747void QNetworkReply::setSslConfigurationImplementation(const QSslConfiguration &)-
748{-
749}-
750-
751/*!-
752 \fn void QNetworkReply::ignoreSslErrorsImplementation(const QList<QSslError> &errors)-
753 \since 5.0-
754-
755 This virtual method is provided to enable overriding the behavior of-
756 ignoreSslErrors(). ignoreSslErrors() is a public wrapper for this method.-
757 \a errors contains the errors the user wishes ignored.-
758-
759 \sa ignoreSslErrors()-
760*/-
761void QNetworkReply::ignoreSslErrorsImplementation(const QList<QSslError> &)-
762{-
763}-
764-
765/*!-
766 If this function is called, SSL errors related to network-
767 connection will be ignored, including certificate validation-
768 errors.-
769-
770 \warning Be sure to always let the user inspect the errors-
771 reported by the sslErrors() signal, and only call this method-
772 upon confirmation from the user that proceeding is ok.-
773 If there are unexpected errors, the reply should be aborted.-
774 Calling this method without inspecting the actual errors will-
775 most likely pose a security risk for your application. Use it-
776 with great care!-
777-
778 This function can be called from the slot connected to the-
779 sslErrors() signal, which indicates which errors were-
780 found.-
781-
782 \sa sslConfiguration(), sslErrors(), QSslSocket::ignoreSslErrors()-
783*/-
784void QNetworkReply::ignoreSslErrors()-
785{-
786}-
787-
788/*!-
789 \internal-
790*/-
791qint64 QNetworkReply::writeData(const char *, qint64)-
792{-
793 return -1; // you can't write
never executed: return -1;
0
794}-
795-
796/*!-
797 Sets the associated operation for this object to be \a-
798 operation. This value will be returned by operation().-
799-
800 \note The operation should be set when this object is created and-
801 not changed again.-
802-
803 \sa operation(), setRequest()-
804*/-
805void QNetworkReply::setOperation(QNetworkAccessManager::Operation operation)-
806{-
807 Q_D(QNetworkReply);-
808 d->operation = operation;-
809}
executed 60 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
60
810-
811/*!-
812 Sets the associated request for this object to be \a request. This-
813 value will be returned by request().-
814-
815 \note The request should be set when this object is created and-
816 not changed again.-
817-
818 \sa request(), setOperation()-
819*/-
820void QNetworkReply::setRequest(const QNetworkRequest &request)-
821{-
822 Q_D(QNetworkReply);-
823 d->originalRequest = request;-
824}
executed 60 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
60
825-
826/*!-
827 Sets the error condition to be \a errorCode. The human-readable-
828 message is set with \a errorString.-
829-
830 Calling setError() does not emit the error(QNetworkReply::NetworkError)-
831 signal.-
832-
833 \sa error(), errorString()-
834*/-
835void QNetworkReply::setError(NetworkError errorCode, const QString &errorString)-
836{-
837 Q_D(QNetworkReply);-
838 d->errorCode = errorCode;-
839 setErrorString(errorString); // in QIODevice-
840}
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
841-
842/*!-
843 \since 4.8-
844 Sets the reply as \a finished.-
845-
846 After having this set the replies data must not change.-
847-
848 \sa isFinished()-
849*/-
850void QNetworkReply::setFinished(bool finished)-
851{-
852 Q_D(QNetworkReply);-
853 d->isFinished = finished;-
854}
executed 1122 times by 9 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlStream
  • tst_Spdy
1122
855-
856-
857/*!-
858 Sets the URL being processed to be \a url. Normally, the URL-
859 matches that of the request that was posted, but for a variety of-
860 reasons it can be different (for example, a file path being made-
861 absolute or canonical).-
862-
863 \sa url(), request(), QNetworkRequest::url()-
864*/-
865void QNetworkReply::setUrl(const QUrl &url)-
866{-
867 Q_D(QNetworkReply);-
868 d->url = url;-
869}
executed 89 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
89
870-
871/*!-
872 Sets the known header \a header to be of value \a value. The-
873 corresponding raw form of the header will be set as well.-
874-
875 \sa header(), setRawHeader(), QNetworkRequest::setHeader()-
876*/-
877void QNetworkReply::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)-
878{-
879 Q_D(QNetworkReply);-
880 d->setCookedHeader(header, value);-
881}
executed 106 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlStream
106
882-
883/*!-
884 Sets the raw header \a headerName to be of value \a value. If \a-
885 headerName was previously set, it is overridden. Multiple HTTP-
886 headers of the same name are functionally equivalent to one single-
887 header with the values concatenated, separated by commas.-
888-
889 If \a headerName matches a known header, the value \a value will-
890 be parsed and the corresponding parsed form will also be set.-
891-
892 \sa rawHeader(), header(), setHeader(), QNetworkRequest::setRawHeader()-
893*/-
894void QNetworkReply::setRawHeader(const QByteArray &headerName, const QByteArray &value)-
895{-
896 Q_D(QNetworkReply);-
897 d->setRawHeader(headerName, value);-
898}
executed 5044 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
5044
899-
900/*!-
901 Sets the attribute \a code to have value \a value. If \a code was-
902 previously set, it will be overridden. If \a value is an invalid-
903 QVariant, the attribute will be unset.-
904-
905 \sa attribute(), QNetworkRequest::setAttribute()-
906*/-
907void QNetworkReply::setAttribute(QNetworkRequest::Attribute code, const QVariant &value)-
908{-
909 Q_D(QNetworkReply);-
910 if (value.isValid())
value.isValid()Description
TRUEevaluated 4842 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
8-4842
911 d->attributes.insert(code, value);
executed 4842 times by 9 tests: d->attributes.insert(code, value);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
4842
912 else-
913 d->attributes.remove(code);
executed 8 times by 1 test: d->attributes.remove(code);
Executed by:
  • tst_QNetworkReply
8
914}-
915-
916QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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