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

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