qnetworkreplyimpl.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkreplyimpl.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 "qnetworkreplyimpl_p.h"-
41#include "qnetworkaccessbackend_p.h"-
42#include "qnetworkcookie.h"-
43#include "qnetworkcookiejar.h"-
44#include "qabstractnetworkcache.h"-
45#include "QtCore/qcoreapplication.h"-
46#include "QtCore/qdatetime.h"-
47#include "QtNetwork/qsslconfiguration.h"-
48#include "QtNetwork/qnetworksession.h"-
49#include "qnetworkaccessmanager_p.h"-
50-
51#include <QtCore/QCoreApplication>-
52-
53QT_BEGIN_NAMESPACE-
54-
55inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate()-
56 : backend(0), outgoingData(0),-
57 copyDevice(0),-
58 cacheEnabled(false), cacheSaveDevice(0),-
59 notificationHandlingPaused(false),-
60 bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1),-
61 httpStatusCode(0),-
62 state(Idle)-
63 , downloadBufferReadPosition(0)-
64 , downloadBufferCurrentSize(0)-
65 , downloadBufferMaximumSize(0)-
66 , downloadBuffer(0)-
67{-
68 if (request.attribute(QNetworkRequest::EmitAllUploadProgressSignalsAttribute).toBool() == true)
request.attrib...Bool() == trueDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-122
69 emitAllUploadProgressSignals = true;
never executed: emitAllUploadProgressSignals = true;
0
70}
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
71-
72void QNetworkReplyImplPrivate::_q_startOperation()-
73{-
74 // ensure this function is only being called once-
75 if (state == Working || state == Finished) {
state == WorkingDescription
TRUEnever evaluated
FALSEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
state == FinishedDescription
TRUEnever evaluated
FALSEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-124
76 qDebug() << "QNetworkReplyImpl::_q_startOperation was called more than once" << url;-
77 return;
never executed: return;
0
78 }-
79 state = Working;-
80-
81 // note: if that method is called directly, it cannot happen that the backend is 0,-
82 // because we just checked via a qobject_cast that we got a http backend (see-
83 // QNetworkReplyImplPrivate::setup())-
84 if (!backend) {
!backendDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 120 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
4-120
85 error(QNetworkReplyImpl::ProtocolUnknownError,-
86 QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); // not really true!;-
87 finished();-
88 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
4
89 }-
90-
91#ifndef QT_NO_BEARERMANAGEMENT-
92 Q_Q(QNetworkReplyImpl);-
93 // Do not start background requests if they are not allowed by session policy-
94 QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession());-
95 QVariant isBackground = backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false));-
96 if (isBackground.toBool() && session && session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy)) {
isBackground.toBool()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 115 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
sessionDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
session->usage...TrafficPolicy)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-115
97 error(QNetworkReply::BackgroundRequestNotAllowedError,-
98 QCoreApplication::translate("QNetworkReply", "Background request not allowed."));-
99 finished();-
100 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
101 }-
102#endif-
103-
104 if (!backend->start()) {
!backend->start()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
3-116
105#ifndef QT_NO_BEARERMANAGEMENT-
106 // backend failed to start because the session state is not Connected.-
107 // QNetworkAccessManager will call _q_startOperation again for us when the session-
108 // state changes.-
109 state = WaitingForSession;-
110-
111 if (session) {
sessionDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-3
112 QObject::connect(session.data(), SIGNAL(error(QNetworkSession::SessionError)),-
113 q, SLOT(_q_networkSessionFailed()));-
114-
115 if (!session->isOpen()) {
!session->isOpen()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-3
116 session->setSessionProperty(QStringLiteral("ConnectInBackground"), isBackground);
executed 3 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QNetworkReply
3
117 session->open();-
118 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
3
119 } else {
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
3
120 qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");-
121 state = Working;-
122 error(QNetworkReplyImpl::NetworkSessionFailedError,-
123 QCoreApplication::translate("QNetworkReply", "Network session error."));-
124 finished();-
125 }
never executed: end of block
0
126#else-
127 qWarning("Backend start failed");-
128 state = Working;-
129 error(QNetworkReplyImpl::UnknownNetworkError,-
130 QCoreApplication::translate("QNetworkReply", "backend start error."));-
131 finished();-
132#endif-
133 return;
executed 3 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
3
134 } else {-
135#ifndef QT_NO_BEARERMANAGEMENT-
136 if (session) {
sessionDescription
TRUEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-116
137 QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)),-
138 q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);-
139 }
executed 116 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
116
140#endif-
141 }
executed 116 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
116
142-
143#ifndef QT_NO_BEARERMANAGEMENT-
144 if (session) {
sessionDescription
TRUEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-116
145 //get notification of policy changes.-
146 QObject::connect(session.data(), SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies)),-
147 q, SLOT(_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies)));-
148 }
executed 116 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
116
149#endif-
150-
151 // Prepare timer for progress notifications-
152 downloadProgressSignalChoke.start();-
153 uploadProgressSignalChoke.invalidate();-
154-
155 if (backend && backend->isSynchronous()) {
backendDescription
TRUEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
backend->isSynchronous()Description
TRUEnever evaluated
FALSEevaluated 116 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-116
156 state = Finished;-
157 q_func()->setFinished(true);-
158 } else {
never executed: end of block
0
159 if (state != Finished) {
state != FinishedDescription
TRUEevaluated 99 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
17-99
160 if (operation == QNetworkAccessManager::GetOperation)
operation == Q...::GetOperationDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 59 times by 1 test
Evaluated by:
  • tst_QNetworkReply
40-59
161 pendingNotifications.append(NotifyDownstreamReadyWrite);
executed 40 times by 1 test: pendingNotifications.append(NotifyDownstreamReadyWrite);
Executed by:
  • tst_QNetworkReply
40
162-
163 handleNotifications();-
164 }
executed 99 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
99
165 }
executed 116 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
116
166}-
167-
168void QNetworkReplyImplPrivate::_q_copyReadyRead()-
169{-
170 Q_Q(QNetworkReplyImpl);-
171 if (state != Working)
state != WorkingDescription
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
172 return;
never executed: return;
0
173 if (!copyDevice || !q->isOpen())
!copyDeviceDescription
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
!q->isOpen()Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
174 return;
never executed: return;
0
175-
176 // FIXME Optimize to use download buffer if it is a QBuffer.-
177 // Needs to be done where sendCacheContents() (?) of HTTP is emitting-
178 // metaDataChanged ?-
179-
180 forever {-
181 qint64 bytesToRead = nextDownstreamBlockSize();-
182 if (bytesToRead == 0)
bytesToRead == 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
183 // we'll be called again, eventually-
184 break;
never executed: break;
0
185-
186 bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());-
187 qint64 bytesActuallyRead = copyDevice->read(buffer.reserve(bytesToRead), bytesToRead);-
188 if (bytesActuallyRead == -1) {
bytesActuallyRead == -1Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
189 buffer.chop(bytesToRead);-
190 backendNotify(NotifyCopyFinished);-
191 break;
never executed: break;
0
192 }-
193 buffer.chop(bytesToRead - bytesActuallyRead);-
194-
195 if (!copyDevice->isSequential() && copyDevice->atEnd()) {
!copyDevice->isSequential()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
copyDevice->atEnd()Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-9
196 backendNotify(NotifyCopyFinished);-
197 bytesDownloaded += bytesActuallyRead;-
198 break;
executed 9 times by 2 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
9
199 }-
200-
201 bytesDownloaded += bytesActuallyRead;-
202 }
never executed: end of block
0
203-
204 if (bytesDownloaded == lastBytesDownloaded) {
bytesDownloade...ytesDownloadedDescription
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
205 // we didn't read anything-
206 return;
never executed: return;
0
207 }-
208-
209 lastBytesDownloaded = bytesDownloaded;-
210 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);-
211 if (preMigrationDownloaded != Q_INT64_C(-1))
preMigrationDo...ng long>(-1LL)Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
212 totalSize = totalSize.toLongLong() + preMigrationDownloaded;
never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded;
0
213 pauseNotificationHandling();-
214 // emit readyRead before downloadProgress incase this will cause events to be-
215 // processed and we get into a recursive call (as in QProgressDialog).-
216 emit q->readyRead();-
217 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
downloadProgre...SignalIntervalDescription
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
218 downloadProgressSignalChoke.restart();-
219 emit q->downloadProgress(bytesDownloaded,-
220 totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());-
221 }
never executed: end of block
0
222 resumeNotificationHandling();-
223}
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
9
224-
225void QNetworkReplyImplPrivate::_q_copyReadChannelFinished()-
226{-
227 _q_copyReadyRead();-
228}
never executed: end of block
0
229-
230void QNetworkReplyImplPrivate::_q_bufferOutgoingDataFinished()-
231{-
232 Q_Q(QNetworkReplyImpl);-
233-
234 // make sure this is only called once, ever.-
235 //_q_bufferOutgoingData may call it or the readChannelFinished emission-
236 if (state != Buffering)
state != BufferingDescription
TRUEnever evaluated
FALSEnever evaluated
0
237 return;
never executed: return;
0
238-
239 // disconnect signals-
240 QObject::disconnect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData()));-
241 QObject::disconnect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished()));-
242-
243 // finally, start the request-
244 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);-
245}
never executed: end of block
0
246-
247void QNetworkReplyImplPrivate::_q_bufferOutgoingData()-
248{-
249 Q_Q(QNetworkReplyImpl);-
250-
251 if (!outgoingDataBuffer) {
!outgoingDataBufferDescription
TRUEnever evaluated
FALSEnever evaluated
0
252 // first call, create our buffer-
253 outgoingDataBuffer = QSharedPointer<QRingBuffer>::create();-
254-
255 QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData()));-
256 QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished()));-
257 }
never executed: end of block
0
258-
259 qint64 bytesBuffered = 0;-
260 qint64 bytesToBuffer = 0;-
261-
262 // read data into our buffer-
263 forever {-
264 bytesToBuffer = outgoingData->bytesAvailable();-
265 // unknown? just try 2 kB, this also ensures we always try to read the EOF-
266 if (bytesToBuffer <= 0)
bytesToBuffer <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
267 bytesToBuffer = 2*1024;
never executed: bytesToBuffer = 2*1024;
0
268-
269 char *dst = outgoingDataBuffer->reserve(bytesToBuffer);-
270 bytesBuffered = outgoingData->read(dst, bytesToBuffer);-
271-
272 if (bytesBuffered == -1) {
bytesBuffered == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
273 // EOF has been reached.-
274 outgoingDataBuffer->chop(bytesToBuffer);-
275-
276 _q_bufferOutgoingDataFinished();-
277 break;
never executed: break;
0
278 } else if (bytesBuffered == 0) {
bytesBuffered == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
279 // nothing read right now, just wait until we get called again-
280 outgoingDataBuffer->chop(bytesToBuffer);-
281-
282 break;
never executed: break;
0
283 } else {-
284 // don't break, try to read() again-
285 outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered);-
286 }
never executed: end of block
0
287 }-
288}
never executed: end of block
0
289-
290#ifndef QT_NO_BEARERMANAGEMENT-
291void QNetworkReplyImplPrivate::_q_networkSessionConnected()-
292{-
293 Q_Q(QNetworkReplyImpl);-
294-
295 if (manager.isNull())
manager.isNull()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-3
296 return;
never executed: return;
0
297-
298 QSharedPointer<QNetworkSession> session = manager->d_func()->getNetworkSession();-
299 if (!session)
!sessionDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-3
300 return;
never executed: return;
0
301-
302 if (session->state() != QNetworkSession::Connected)
session->state...ion::ConnectedDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-3
303 return;
never executed: return;
0
304-
305 switch (state) {-
306 case QNetworkReplyPrivate::Buffering:
never executed: case QNetworkReplyPrivate::Buffering:
0
307 case QNetworkReplyPrivate::Working:
never executed: case QNetworkReplyPrivate::Working:
0
308 case QNetworkReplyPrivate::Reconnecting:
never executed: case QNetworkReplyPrivate::Reconnecting:
0
309 // Migrate existing downloads to new network connection.-
310 migrateBackend();-
311 break;
never executed: break;
0
312 case QNetworkReplyPrivate::WaitingForSession:
executed 3 times by 1 test: case QNetworkReplyPrivate::WaitingForSession:
Executed by:
  • tst_QNetworkReply
3
313 // Start waiting requests.-
314 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);-
315 break;
executed 3 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
3
316 default:
never executed: default:
0
317 ;-
318 }
never executed: end of block
0
319}-
320-
321void QNetworkReplyImplPrivate::_q_networkSessionStateChanged(QNetworkSession::State sessionState)-
322{-
323 if (sessionState == QNetworkSession::Disconnected
sessionState =...::DisconnectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
324 && state != Idle && state != Reconnecting) {
state != IdleDescription
TRUEnever evaluated
FALSEnever evaluated
state != ReconnectingDescription
TRUEnever evaluated
FALSEnever evaluated
0
325 error(QNetworkReplyImpl::NetworkSessionFailedError,-
326 QCoreApplication::translate("QNetworkReply", "Network session error."));-
327 finished();-
328 }
never executed: end of block
0
329}
never executed: end of block
0
330-
331void QNetworkReplyImplPrivate::_q_networkSessionFailed()-
332{-
333 // Abort waiting and working replies.-
334 if (state == WaitingForSession || state == Working) {
state == WaitingForSessionDescription
TRUEnever evaluated
FALSEnever evaluated
state == WorkingDescription
TRUEnever evaluated
FALSEnever evaluated
0
335 state = Working;-
336 QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession());-
337 QString errorStr;-
338 if (session)
sessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
339 errorStr = session->errorString();
never executed: errorStr = session->errorString();
0
340 else-
341 errorStr = QCoreApplication::translate("QNetworkReply", "Network session error.");
never executed: errorStr = QCoreApplication::translate("QNetworkReply", "Network session error.");
0
342 error(QNetworkReplyImpl::NetworkSessionFailedError, errorStr);-
343 finished();-
344 }
never executed: end of block
0
345}
never executed: end of block
0
346-
347void QNetworkReplyImplPrivate::_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies newPolicies)-
348{-
349 if (backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute).toBool()) {
backend->reque...bute).toBool()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-3
350 if (newPolicies & QNetworkSession::NoBackgroundTrafficPolicy) {
newPolicies & ...dTrafficPolicyDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1
351 // Abort waiting and working replies.-
352 if (state == WaitingForSession || state == Working) {
state == WaitingForSessionDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
state == WorkingDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
353 state = Working;-
354 error(QNetworkReply::BackgroundRequestNotAllowedError,-
355 QCoreApplication::translate("QNetworkReply", "Background request not allowed."));-
356 finished();-
357 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
358 // ### if backend->canResume(), then we could resume automatically, however no backend supports resuming-
359 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
360 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
2
361}
executed 5 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
5
362#endif-
363-
364void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,-
365 QIODevice *data)-
366{-
367 Q_Q(QNetworkReplyImpl);-
368-
369 outgoingData = data;-
370 request = req;-
371 url = request.url();-
372 operation = op;-
373-
374 q->QIODevice::open(QIODevice::ReadOnly);-
375 // Internal code that does a HTTP reply for the synchronous Ajax-
376 // in Qt WebKit.-
377 QVariant synchronousHttpAttribute = req.attribute(-
378 static_cast<QNetworkRequest::Attribute>(QNetworkRequest::SynchronousRequestAttribute));-
379 // The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer.-
380 // Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway.-
381 if (synchronousHttpAttribute.toBool() && outgoingData) {
synchronousHtt...ibute.toBool()Description
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
outgoingDataDescription
TRUEnever evaluated
FALSEnever evaluated
0-122
382 outgoingDataBuffer = QSharedPointer<QRingBuffer>::create();-
383 qint64 previousDataSize = 0;-
384 do {-
385 previousDataSize = outgoingDataBuffer->size();-
386 outgoingDataBuffer->append(outgoingData->readAll());-
387 } while (outgoingDataBuffer->size() != previousDataSize);
never executed: end of block
outgoingDataBu...eviousDataSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
388 }
never executed: end of block
0
389-
390 if (backend)
backendDescription
TRUEevaluated 118 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
4-118
391 backend->setSynchronous(synchronousHttpAttribute.toBool());
executed 118 times by 3 tests: backend->setSynchronous(synchronousHttpAttribute.toBool());
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
118
392-
393-
394 if (outgoingData && backend && !backend->isSynchronous()) {
outgoingDataDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
backendDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
!backend->isSynchronous()Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-63
395 // there is data to be uploaded, e.g. HTTP POST.-
396-
397 if (!backend->needsResetableUploadData() || !outgoingData->isSequential()) {
!backend->need...leUploadData()Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
!outgoingData->isSequential()Description
TRUEnever evaluated
FALSEnever evaluated
0-59
398 // backend does not need upload buffering or-
399 // fixed size non-sequential-
400 // just start the operation-
401 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);-
402 } else {
executed 59 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
59
403 bool bufferingDisallowed =-
404 req.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute,-
405 false).toBool();-
406-
407 if (bufferingDisallowed) {
bufferingDisallowedDescription
TRUEnever evaluated
FALSEnever evaluated
0
408 // if a valid content-length header for the request was supplied, we can disable buffering-
409 // if not, we will buffer anyway-
410 if (req.header(QNetworkRequest::ContentLengthHeader).isValid()) {
req.header(QNe...der).isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
411 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);-
412 } else {
never executed: end of block
0
413 state = Buffering;-
414 QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection);-
415 }
never executed: end of block
0
416 } else {-
417 // _q_startOperation will be called when the buffering has finished.-
418 state = Buffering;-
419 QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection);-
420 }
never executed: end of block
0
421 }-
422 } else {-
423 // for HTTP, we want to send out the request as fast as possible to the network, without-
424 // invoking methods in a QueuedConnection-
425 if (backend && backend->isSynchronous())
backendDescription
TRUEevaluated 59 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
backend->isSynchronous()Description
TRUEnever evaluated
FALSEevaluated 59 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-59
426 _q_startOperation();
never executed: _q_startOperation();
0
427 else-
428 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
executed 63 times by 3 tests: QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
63
429 }-
430}-
431-
432void QNetworkReplyImplPrivate::backendNotify(InternalNotifications notification)-
433{-
434 Q_Q(QNetworkReplyImpl);-
435 if (!pendingNotifications.contains(notification))
!pendingNotifi...(notification)Description
TRUEevaluated 463 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 173 times by 1 test
Evaluated by:
  • tst_QNetworkReply
173-463
436 pendingNotifications.enqueue(notification);
executed 463 times by 2 tests: pendingNotifications.enqueue(notification);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
463
437-
438 if (pendingNotifications.size() == 1)
pendingNotific...ns.size() == 1Description
TRUEevaluated 636 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-636
439 QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated));
executed 636 times by 2 tests: QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
636
440}
executed 636 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
636
441-
442void QNetworkReplyImplPrivate::handleNotifications()-
443{-
444 if (notificationHandlingPaused)
notificationHandlingPausedDescription
TRUEnever evaluated
FALSEevaluated 817 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-817
445 return;
never executed: return;
0
446-
447 NotificationQueue current = pendingNotifications;-
448 pendingNotifications.clear();-
449-
450 if (state != Working)
state != WorkingDescription
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 800 times by 1 test
Evaluated by:
  • tst_QNetworkReply
17-800
451 return;
executed 17 times by 2 tests: return;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
17
452-
453 while (state == Working && !current.isEmpty()) {
state == WorkingDescription
TRUEevaluated 1285 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!current.isEmpty()Description
TRUEevaluated 489 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 796 times by 1 test
Evaluated by:
  • tst_QNetworkReply
4-1285
454 InternalNotifications notification = current.dequeue();-
455 switch (notification) {-
456 case NotifyDownstreamReadyWrite:
executed 489 times by 1 test: case NotifyDownstreamReadyWrite:
Executed by:
  • tst_QNetworkReply
489
457 if (copyDevice)
copyDeviceDescription
TRUEnever evaluated
FALSEevaluated 489 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-489
458 _q_copyReadyRead();
never executed: _q_copyReadyRead();
0
459 else-
460 backend->downstreamReadyWrite();
executed 489 times by 1 test: backend->downstreamReadyWrite();
Executed by:
  • tst_QNetworkReply
489
461 break;
executed 489 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
489
462-
463 case NotifyCloseDownstreamChannel:
never executed: case NotifyCloseDownstreamChannel:
0
464 backend->closeDownstreamChannel();-
465 break;
never executed: break;
0
466-
467 case NotifyCopyFinished: {
never executed: case NotifyCopyFinished:
0
468 QIODevice *dev = copyDevice;-
469 copyDevice = 0;-
470 backend->copyFinished(dev);-
471 break;
never executed: break;
0
472 }-
473 }-
474 }
executed 489 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
489
475}
executed 800 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
800
476-
477// Do not handle the notifications while we are emitting downloadProgress-
478// or readyRead-
479void QNetworkReplyImplPrivate::pauseNotificationHandling()-
480{-
481 notificationHandlingPaused = true;-
482}
executed 1506 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
1506
483-
484// Resume notification handling-
485void QNetworkReplyImplPrivate::resumeNotificationHandling()-
486{-
487 Q_Q(QNetworkReplyImpl);-
488 notificationHandlingPaused = false;-
489 if (pendingNotifications.size() >= 1)
pendingNotific...ns.size() >= 1Description
TRUEevaluated 181 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 1325 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
181-1325
490 QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated));
executed 181 times by 2 tests: QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
181
491}
executed 1506 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
1506
492-
493QAbstractNetworkCache *QNetworkReplyImplPrivate::networkCache() const-
494{-
495 if (!backend)
!backendDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-30
496 return 0;
never executed: return 0;
0
497 return backend->networkCache();
executed 30 times by 1 test: return backend->networkCache();
Executed by:
  • tst_QNetworkReply
30
498}-
499-
500void QNetworkReplyImplPrivate::createCache()-
501{-
502 // check if we can save and if we're allowed to-
503 if (!networkCache()
!networkCache()Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-30
504 || !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool())
!request.attri...true).toBool()Description
TRUEnever evaluated
FALSEnever evaluated
0
505 return;
executed 30 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
30
506 cacheEnabled = true;-
507}
never executed: end of block
0
508-
509bool QNetworkReplyImplPrivate::isCachingEnabled() const-
510{-
511 return (cacheEnabled && networkCache() != 0);
executed 122 times by 3 tests: return (cacheEnabled && networkCache() != 0);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
512}-
513-
514void QNetworkReplyImplPrivate::setCachingEnabled(bool enable)-
515{-
516 if (!enable && !cacheEnabled)
!enableDescription
TRUEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!cacheEnabledDescription
TRUEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-30
517 return; // nothing to do
executed 13 times by 2 tests: return;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
13
518 if (enable && cacheEnabled)
enableDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
cacheEnabledDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-30
519 return; // nothing to do either!
never executed: return;
0
520-
521 if (enable) {
enableDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-30
522 if (Q_UNLIKELY(bytesDownloaded)) {
__builtin_expe...oaded), false)Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-30
523 // refuse to enable in this case-
524 qCritical("QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written");-
525 return;
never executed: return;
0
526 }-
527-
528 createCache();-
529 } else {
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
30
530 // someone told us to turn on, then back off?-
531 // ok... but you should make up your mind-
532 qDebug("QNetworkReplyImpl: setCachingEnabled(true) called after setCachingEnabled(false) -- "-
533 "backend %s probably needs to be fixed",-
534 backend->metaObject()->className());-
535 networkCache()->remove(url);-
536 cacheSaveDevice = 0;-
537 cacheEnabled = false;-
538 }
never executed: end of block
0
539}-
540-
541void QNetworkReplyImplPrivate::completeCacheSave()-
542{-
543 if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) {
cacheEnabledDescription
TRUEnever evaluated
FALSEevaluated 119 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
errorCode != Q...yImpl::NoErrorDescription
TRUEnever evaluated
FALSEnever evaluated
0-119
544 networkCache()->remove(url);-
545 } else if (cacheEnabled && cacheSaveDevice) {
never executed: end of block
cacheEnabledDescription
TRUEnever evaluated
FALSEevaluated 119 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0-119
546 networkCache()->insert(cacheSaveDevice);-
547 }
never executed: end of block
0
548 cacheSaveDevice = 0;-
549 cacheEnabled = false;-
550}
executed 119 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
119
551-
552void QNetworkReplyImplPrivate::emitUploadProgress(qint64 bytesSent, qint64 bytesTotal)-
553{-
554 Q_Q(QNetworkReplyImpl);-
555 bytesUploaded = bytesSent;-
556-
557 if (!emitAllUploadProgressSignals) {
!emitAllUploadProgressSignalsDescription
TRUEevaluated 1053 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1053
558 //choke signal emissions, except the first and last signals which are unconditional-
559 if (uploadProgressSignalChoke.isValid()) {
uploadProgress...hoke.isValid()Description
TRUEevaluated 1000 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 53 times by 1 test
Evaluated by:
  • tst_QNetworkReply
53-1000
560 if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) {
bytesSent != bytesTotalDescription
TRUEevaluated 410 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 590 times by 1 test
Evaluated by:
  • tst_QNetworkReply
uploadProgress...SignalIntervalDescription
TRUEevaluated 410 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-590
561 return;
executed 410 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
410
562 }-
563 uploadProgressSignalChoke.restart();-
564 } else {
executed 590 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
590
565 uploadProgressSignalChoke.start();-
566 }
executed 53 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
53
567 }-
568-
569 pauseNotificationHandling();-
570 emit q->uploadProgress(bytesSent, bytesTotal);-
571 resumeNotificationHandling();-
572}
executed 643 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
643
573-
574-
575qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const-
576{-
577 enum { DesiredBufferSize = 32 * 1024 };-
578 if (readBufferMaxSize == 0)
readBufferMaxSize == 0Description
TRUEevaluated 529 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
6-529
579 return DesiredBufferSize;
executed 529 times by 2 tests: return DesiredBufferSize;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
529
580-
581 return qMax<qint64>(0, readBufferMaxSize - buffer.size());
executed 6 times by 1 test: return qMax<qint64>(0, readBufferMaxSize - buffer.size());
Executed by:
  • tst_QNetworkReply
6
582}-
583-
584void QNetworkReplyImplPrivate::initCacheSaveDevice()-
585{-
586 Q_Q(QNetworkReplyImpl);-
587-
588 // The disk cache does not support partial content, so don't even try to-
589 // save any such content into the cache.-
590 if (q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206) {
q->attribute(Q...toInt() == 206Description
TRUEnever evaluated
FALSEnever evaluated
0
591 cacheEnabled = false;-
592 return;
never executed: return;
0
593 }-
594-
595 // save the meta data-
596 QNetworkCacheMetaData metaData;-
597 metaData.setUrl(url);-
598 metaData = backend->fetchCacheMetaData(metaData);-
599-
600 // save the redirect request also in the cache-
601 QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);-
602 if (redirectionTarget.isValid()) {
redirectionTarget.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
603 QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes();-
604 attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget);-
605 metaData.setAttributes(attributes);-
606 }
never executed: end of block
0
607-
608 cacheSaveDevice = networkCache()->prepare(metaData);-
609-
610 if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
!cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
!cacheSaveDevice->isOpen()Description
TRUEnever evaluated
FALSEnever evaluated
0
611 if (Q_UNLIKELY(cacheSaveDevice && !cacheSaveDevice->isOpen()))
__builtin_expe...pen()), false)Description
TRUEnever evaluated
FALSEnever evaluated
0
612 qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
never executed: QMessageLogger(__FILE__, 612, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " "class %s probably needs to be fixed", networkCache()->metaObject()->className());
0
613 "class %s probably needs to be fixed",
never executed: QMessageLogger(__FILE__, 612, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " "class %s probably needs to be fixed", networkCache()->metaObject()->className());
0
614 networkCache()->metaObject()->className());
never executed: QMessageLogger(__FILE__, 612, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " "class %s probably needs to be fixed", networkCache()->metaObject()->className());
0
615-
616 networkCache()->remove(url);-
617 cacheSaveDevice = 0;-
618 cacheEnabled = false;-
619 }
never executed: end of block
0
620}
never executed: end of block
0
621-
622// we received downstream data and send this to the cache-
623// and to our buffer (which in turn gets read by the user of QNetworkReply)-
624void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)-
625{-
626 Q_Q(QNetworkReplyImpl);-
627 if (!q->isOpen())
!q->isOpen()Description
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-488
628 return;
never executed: return;
0
629-
630 if (cacheEnabled && !cacheSaveDevice) {
cacheEnabledDescription
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0-488
631 initCacheSaveDevice();-
632 }
never executed: end of block
0
633-
634 qint64 bytesWritten = 0;-
635 for (int i = 0; i < data.bufferCount(); i++) {
i < data.bufferCount()Description
TRUEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
488
636 QByteArray const &item = data[i];-
637-
638 if (cacheSaveDevice)
cacheSaveDeviceDescription
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-488
639 cacheSaveDevice->write(item.constData(), item.size());
never executed: cacheSaveDevice->write(item.constData(), item.size());
0
640 buffer.append(item);-
641-
642 bytesWritten += item.size();-
643 }
executed 488 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
488
644 data.clear();-
645-
646 bytesDownloaded += bytesWritten;-
647 lastBytesDownloaded = bytesDownloaded;-
648-
649 appendDownstreamDataSignalEmissions();-
650}
executed 488 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
488
651-
652void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()-
653{-
654 Q_Q(QNetworkReplyImpl);-
655-
656 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);-
657 if (preMigrationDownloaded != Q_INT64_C(-1))
preMigrationDo...ng long>(-1LL)Description
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-488
658 totalSize = totalSize.toLongLong() + preMigrationDownloaded;
never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded;
0
659 pauseNotificationHandling();-
660 // important: At the point of this readyRead(), the data parameter list must be empty,-
661 // else implicit sharing will trigger memcpy when the user is reading data!-
662 emit q->readyRead();-
663 // emit readyRead before downloadProgress incase this will cause events to be-
664 // processed and we get into a recursive call (as in QProgressDialog).-
665 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
downloadProgre...SignalIntervalDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 486 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-486
666 downloadProgressSignalChoke.restart();-
667 emit q->downloadProgress(bytesDownloaded,-
668 totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());-
669 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
2
670-
671 resumeNotificationHandling();-
672 // do we still have room in the buffer?-
673 if (nextDownstreamBlockSize() > 0)
nextDownstreamBlockSize() > 0Description
TRUEevaluated 482 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
6-482
674 backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
executed 482 times by 1 test: backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
Executed by:
  • tst_QNetworkReply
482
675}
executed 488 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
488
676-
677// this is used when it was fetched from the cache, right?-
678void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)-
679{-
680 Q_Q(QNetworkReplyImpl);-
681 if (!q->isOpen())
!q->isOpen()Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
682 return;
never executed: return;
0
683-
684 // read until EOF from data-
685 if (Q_UNLIKELY(copyDevice)) {
__builtin_expe...evice), false)Description
TRUEnever evaluated
FALSEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-9
686 qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "-
687 "backend probly needs to be fixed");-
688 return;
never executed: return;
0
689 }-
690-
691 copyDevice = data;-
692 q->connect(copyDevice, SIGNAL(readyRead()), SLOT(_q_copyReadyRead()));-
693 q->connect(copyDevice, SIGNAL(readChannelFinished()), SLOT(_q_copyReadChannelFinished()));-
694-
695 // start the copy:-
696 _q_copyReadyRead();-
697}
executed 9 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
9
698-
699void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data)-
700{-
701 Q_UNUSED(data)-
702 // TODO implement-
703-
704 // TODO call-
705-
706 qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented");-
707}
never executed: end of block
0
708-
709static void downloadBufferDeleter(char *ptr)-
710{-
711 delete[] ptr;-
712}
never executed: end of block
0
713-
714char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size)-
715{-
716 Q_Q(QNetworkReplyImpl);-
717-
718 if (!downloadBuffer) {
!downloadBufferDescription
TRUEnever evaluated
FALSEnever evaluated
0
719 // We are requested to create it-
720 // Check attribute() if allocating a buffer of that size can be allowed-
721 QVariant bufferAllocationPolicy = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute);-
722 if (bufferAllocationPolicy.isValid() && bufferAllocationPolicy.toLongLong() >= size) {
bufferAllocati...licy.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
bufferAllocati...Long() >= sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
723 downloadBufferCurrentSize = 0;-
724 downloadBufferMaximumSize = size;-
725 downloadBuffer = new char[downloadBufferMaximumSize]; // throws if allocation fails-
726 downloadBufferPointer = QSharedPointer<char>(downloadBuffer, downloadBufferDeleter);-
727-
728 q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer));-
729 }
never executed: end of block
0
730 }
never executed: end of block
0
731-
732 return downloadBuffer;
never executed: return downloadBuffer;
0
733}-
734-
735void QNetworkReplyImplPrivate::setDownloadBuffer(QSharedPointer<char> sp, qint64 size)-
736{-
737 Q_Q(QNetworkReplyImpl);-
738-
739 downloadBufferPointer = sp;-
740 downloadBuffer = downloadBufferPointer.data();-
741 downloadBufferCurrentSize = 0;-
742 downloadBufferMaximumSize = size;-
743 q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer));-
744}
never executed: end of block
0
745-
746-
747void QNetworkReplyImplPrivate::appendDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal)-
748{-
749 Q_Q(QNetworkReplyImpl);-
750 if (!q->isOpen())
!q->isOpen()Description
TRUEnever evaluated
FALSEnever evaluated
0
751 return;
never executed: return;
0
752-
753 if (cacheEnabled && !cacheSaveDevice)
cacheEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
!cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0
754 initCacheSaveDevice();
never executed: initCacheSaveDevice();
0
755-
756 if (cacheSaveDevice && bytesReceived == bytesTotal) {
cacheSaveDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
bytesReceived == bytesTotalDescription
TRUEnever evaluated
FALSEnever evaluated
0
757// if (lastBytesDownloaded == -1)-
758// lastBytesDownloaded = 0;-
759// cacheSaveDevice->write(downloadBuffer + lastBytesDownloaded, bytesReceived - lastBytesDownloaded);-
760-
761 // Write everything in one go if we use a download buffer. might be more performant.-
762 cacheSaveDevice->write(downloadBuffer, bytesTotal);-
763 }
never executed: end of block
0
764-
765 bytesDownloaded = bytesReceived;-
766 lastBytesDownloaded = bytesReceived;-
767-
768 downloadBufferCurrentSize = bytesReceived;-
769-
770 // Only emit readyRead when actual data is there-
771 // emit readyRead before downloadProgress incase this will cause events to be-
772 // processed and we get into a recursive call (as in QProgressDialog).-
773 if (bytesDownloaded > 0)
bytesDownloaded > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
774 emit q->readyRead();
never executed: q->readyRead();
0
775 if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
downloadProgre...SignalIntervalDescription
TRUEnever evaluated
FALSEnever evaluated
0
776 downloadProgressSignalChoke.restart();-
777 emit q->downloadProgress(bytesDownloaded, bytesTotal);-
778 }
never executed: end of block
0
779}
never executed: end of block
0
780-
781void QNetworkReplyImplPrivate::finished()-
782{-
783 Q_Q(QNetworkReplyImpl);-
784-
785 if (state == Finished || state == Aborted || state == WaitingForSession)
state == FinishedDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
state == AbortedDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
state == WaitingForSessionDescription
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-122
786 return;
never executed: return;
0
787-
788 pauseNotificationHandling();-
789 QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);-
790 if (preMigrationDownloaded != Q_INT64_C(-1))
preMigrationDo...ng long>(-1LL)Description
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-122
791 totalSize = totalSize.toLongLong() + preMigrationDownloaded;
never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded;
0
792-
793 if (!manager.isNull()) {
!manager.isNull()Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEnever evaluated
0-122
794#ifndef QT_NO_BEARERMANAGEMENT-
795 QSharedPointer<QNetworkSession> session (manager->d_func()->getNetworkSession());-
796 if (session && session->state() == QNetworkSession::Roaming &&
sessionDescription
TRUEevaluated 121 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkAccessManager
session->state...ssion::RoamingDescription
TRUEnever evaluated
FALSEevaluated 121 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-121
797 state == Working && errorCode != QNetworkReply::OperationCanceledError) {
state == WorkingDescription
TRUEnever evaluated
FALSEnever evaluated
errorCode != Q...nCanceledErrorDescription
TRUEnever evaluated
FALSEnever evaluated
0
798 // only content with a known size will fail with a temporary network failure error-
799 if (!totalSize.isNull()) {
!totalSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
800 if (bytesDownloaded != totalSize) {
bytesDownloaded != totalSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
801 if (migrateBackend()) {
migrateBackend()Description
TRUEnever evaluated
FALSEnever evaluated
0
802 // either we are migrating or the request is finished/aborted-
803 if (state == Reconnecting || state == WaitingForSession) {
state == ReconnectingDescription
TRUEnever evaluated
FALSEnever evaluated
state == WaitingForSessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
804 resumeNotificationHandling();-
805 return; // exit early if we are migrating.
never executed: return;
0
806 }-
807 } else {
never executed: end of block
0
808 error(QNetworkReply::TemporaryNetworkFailureError,-
809 QNetworkReply::tr("Temporary network failure."));-
810 }
never executed: end of block
0
811 }-
812 }
never executed: end of block
0
813 }
never executed: end of block
0
814#endif-
815 }
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
816 resumeNotificationHandling();-
817-
818 state = Finished;-
819 q->setFinished(true);-
820-
821 pendingNotifications.clear();-
822-
823 pauseNotificationHandling();-
824 if (totalSize.isNull() || totalSize == -1) {
totalSize.isNull()Description
TRUEevaluated 88 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
totalSize == -1Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-88
825 emit q->downloadProgress(bytesDownloaded, bytesDownloaded);-
826 } else {
executed 88 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
88
827 emit q->downloadProgress(bytesDownloaded, totalSize.toLongLong());-
828 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
34
829-
830 if (bytesUploaded == -1 && (outgoingData || outgoingDataBuffer))
bytesUploaded == -1Description
TRUEevaluated 69 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 53 times by 1 test
Evaluated by:
  • tst_QNetworkReply
outgoingDataDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
outgoingDataBufferDescription
TRUEnever evaluated
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-69
831 emit q->uploadProgress(0, 0);
executed 6 times by 1 test: q->uploadProgress(0, 0);
Executed by:
  • tst_QNetworkReply
6
832 resumeNotificationHandling();-
833-
834 // if we don't know the total size of or we received everything save the cache-
835 if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize)
totalSize.isNull()Description
TRUEevaluated 88 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
totalSize == -1Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
bytesDownloaded == totalSizeDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-88
836 completeCacheSave();
executed 119 times by 3 tests: completeCacheSave();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
119
837-
838 // note: might not be a good idea, since users could decide to delete us-
839 // which would delete the backend too...-
840 // maybe we should protect the backend-
841 pauseNotificationHandling();-
842 emit q->readChannelFinished();-
843 emit q->finished();-
844 resumeNotificationHandling();-
845}
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
846-
847void QNetworkReplyImplPrivate::error(QNetworkReplyImpl::NetworkError code, const QString &errorMessage)-
848{-
849 Q_Q(QNetworkReplyImpl);-
850 // Can't set and emit multiple errors.-
851 if (errorCode != QNetworkReply::NoError) {
errorCode != Q...Reply::NoErrorDescription
TRUEnever evaluated
FALSEevaluated 25 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-25
852 qWarning( "QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.");-
853 return;
never executed: return;
0
854 }-
855-
856 errorCode = code;-
857 q->setErrorString(errorMessage);-
858-
859 // note: might not be a good idea, since users could decide to delete us-
860 // which would delete the backend too...-
861 // maybe we should protect the backend-
862 emit q->error(code);-
863}
executed 25 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
25
864-
865void QNetworkReplyImplPrivate::metaDataChanged()-
866{-
867 Q_Q(QNetworkReplyImpl);-
868 // 1. do we have cookies?-
869 // 2. are we allowed to set them?-
870 if (!manager.isNull()) {
!manager.isNull()Description
TRUEevaluated 54 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEnever evaluated
0-54
871 const auto it = cookedHeaders.constFind(QNetworkRequest::SetCookieHeader);-
872 if (it != cookedHeaders.cend()
it != cookedHeaders.cend()Description
TRUEnever evaluated
FALSEevaluated 54 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-54
873 && request.attribute(QNetworkRequest::CookieSaveControlAttribute,
request.attrib...est::AutomaticDescription
TRUEnever evaluated
FALSEnever evaluated
0
874 QNetworkRequest::Automatic).toInt() == QNetworkRequest::Automatic) {
request.attrib...est::AutomaticDescription
TRUEnever evaluated
FALSEnever evaluated
0
875 QNetworkCookieJar *jar = manager->cookieJar();-
876 if (jar) {
jarDescription
TRUEnever evaluated
FALSEnever evaluated
0
877 QList<QNetworkCookie> cookies =-
878 qvariant_cast<QList<QNetworkCookie> >(it.value());-
879 jar->setCookiesFromUrl(cookies, url);-
880 }
never executed: end of block
0
881 }
never executed: end of block
0
882 }
executed 54 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
54
883-
884 emit q->metaDataChanged();-
885}
executed 54 times by 2 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
54
886-
887void QNetworkReplyImplPrivate::redirectionRequested(const QUrl &target)-
888{-
889 attributes.insert(QNetworkRequest::RedirectionTargetAttribute, target);-
890}
never executed: end of block
0
891-
892void QNetworkReplyImplPrivate::encrypted()-
893{-
894#ifndef QT_NO_SSL-
895 Q_Q(QNetworkReplyImpl);-
896 emit q->encrypted();-
897#endif-
898}
never executed: end of block
0
899-
900void QNetworkReplyImplPrivate::sslErrors(const QList<QSslError> &errors)-
901{-
902#ifndef QT_NO_SSL-
903 Q_Q(QNetworkReplyImpl);-
904 emit q->sslErrors(errors);-
905#else-
906 Q_UNUSED(errors);-
907#endif-
908}
never executed: end of block
0
909-
910QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent)-
911 : QNetworkReply(*new QNetworkReplyImplPrivate, parent)-
912{-
913}
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
914-
915QNetworkReplyImpl::~QNetworkReplyImpl()-
916{-
917 Q_D(QNetworkReplyImpl);-
918-
919 // This code removes the data from the cache if it was prematurely aborted.-
920 // See QNetworkReplyImplPrivate::completeCacheSave(), we disable caching there after the cache-
921 // save had been properly finished. So if it is still enabled it means we got deleted/aborted.-
922 if (d->isCachingEnabled())
d->isCachingEnabled()Description
TRUEnever evaluated
FALSEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-122
923 d->networkCache()->remove(url());
never executed: d->networkCache()->remove(url());
0
924}
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
122
925-
926void QNetworkReplyImpl::abort()-
927{-
928 Q_D(QNetworkReplyImpl);-
929 if (d->state == QNetworkReplyPrivate::Finished || d->state == QNetworkReplyPrivate::Aborted)
d->state == QN...vate::FinishedDescription
TRUEnever evaluated
FALSEnever evaluated
d->state == QN...ivate::AbortedDescription
TRUEnever evaluated
FALSEnever evaluated
0
930 return;
never executed: return;
0
931-
932 // stop both upload and download-
933 if (d->outgoingData)
d->outgoingDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
934 disconnect(d->outgoingData, 0, this, 0);
never executed: disconnect(d->outgoingData, 0, this, 0);
0
935 if (d->copyDevice)
d->copyDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0
936 disconnect(d->copyDevice, 0, this, 0);
never executed: disconnect(d->copyDevice, 0, this, 0);
0
937-
938 QNetworkReply::close();-
939-
940 // call finished which will emit signals-
941 d->error(OperationCanceledError, tr("Operation canceled"));-
942 if (d->state == QNetworkReplyPrivate::WaitingForSession)
d->state == QN...tingForSessionDescription
TRUEnever evaluated
FALSEnever evaluated
0
943 d->state = QNetworkReplyPrivate::Working;
never executed: d->state = QNetworkReplyPrivate::Working;
0
944 d->finished();-
945 d->state = QNetworkReplyPrivate::Aborted;-
946-
947 // finished may access the backend-
948 if (d->backend) {
d->backendDescription
TRUEnever evaluated
FALSEnever evaluated
0
949 d->backend->deleteLater();-
950 d->backend = 0;-
951 }
never executed: end of block
0
952}
never executed: end of block
0
953-
954void QNetworkReplyImpl::close()-
955{-
956 Q_D(QNetworkReplyImpl);-
957 if (d->state == QNetworkReplyPrivate::Aborted ||
d->state == QN...ivate::AbortedDescription
TRUEnever evaluated
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-15
958 d->state == QNetworkReplyPrivate::Finished)
d->state == QN...vate::FinishedDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
2-13
959 return;
executed 13 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
13
960-
961 // stop the download-
962 if (d->backend)
d->backendDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
FALSEnever evaluated
0-2
963 d->backend->closeDownstreamChannel();
executed 2 times by 2 tests: d->backend->closeDownstreamChannel();
Executed by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
2
964 if (d->copyDevice)
d->copyDeviceDescription
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
0-2
965 disconnect(d->copyDevice, 0, this, 0);
never executed: disconnect(d->copyDevice, 0, this, 0);
0
966-
967 QNetworkReply::close();-
968-
969 // call finished which will emit signals-
970 d->error(OperationCanceledError, tr("Operation canceled"));-
971 d->finished();-
972}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
2
973-
974/*!-
975 Returns the number of bytes available for reading with-
976 QIODevice::read(). The number of bytes available may grow until-
977 the finished() signal is emitted.-
978*/-
979qint64 QNetworkReplyImpl::bytesAvailable() const-
980{-
981 // Special case for the "zero copy" download buffer-
982 Q_D(const QNetworkReplyImpl);-
983 if (d->downloadBuffer) {
d->downloadBufferDescription
TRUEnever evaluated
FALSEevaluated 286 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-286
984 qint64 maxAvail = d->downloadBufferCurrentSize - d->downloadBufferReadPosition;-
985 return QNetworkReply::bytesAvailable() + maxAvail;
never executed: return QNetworkReply::bytesAvailable() + maxAvail;
0
986 }-
987-
988 return QNetworkReply::bytesAvailable();
executed 286 times by 1 test: return QNetworkReply::bytesAvailable();
Executed by:
  • tst_QNetworkReply
286
989}-
990-
991void QNetworkReplyImpl::setReadBufferSize(qint64 size)-
992{-
993 Q_D(QNetworkReplyImpl);-
994 if (size > d->readBufferMaxSize &&
size > d->readBufferMaxSizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2
995 size > d->buffer.size())
size > d->buffer.size()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-2
996 d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
executed 2 times by 1 test: d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);
Executed by:
  • tst_QNetworkReply
2
997-
998 QNetworkReply::setReadBufferSize(size);-
999-
1000 if (d->backend)
d->backendDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-4
1001 d->backend->setDownstreamLimited(d->readBufferMaxSize > 0);
executed 4 times by 1 test: d->backend->setDownstreamLimited(d->readBufferMaxSize > 0);
Executed by:
  • tst_QNetworkReply
4
1002}
executed 4 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
4
1003-
1004#ifndef QT_NO_SSL-
1005void QNetworkReplyImpl::sslConfigurationImplementation(QSslConfiguration &configuration) const-
1006{-
1007 Q_D(const QNetworkReplyImpl);-
1008 if (d->backend)
d->backendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1009 d->backend->fetchSslConfiguration(configuration);
never executed: d->backend->fetchSslConfiguration(configuration);
0
1010}
never executed: end of block
0
1011-
1012void QNetworkReplyImpl::setSslConfigurationImplementation(const QSslConfiguration &config)-
1013{-
1014 Q_D(QNetworkReplyImpl);-
1015 if (d->backend && !config.isNull())
d->backendDescription
TRUEevaluated 104 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!config.isNull()Description
TRUEevaluated 104 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-104
1016 d->backend->setSslConfiguration(config);
executed 104 times by 1 test: d->backend->setSslConfiguration(config);
Executed by:
  • tst_QNetworkReply
104
1017}
executed 108 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
108
1018-
1019void QNetworkReplyImpl::ignoreSslErrors()-
1020{-
1021 Q_D(QNetworkReplyImpl);-
1022 if (d->backend)
d->backendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1023 d->backend->ignoreSslErrors();
never executed: d->backend->ignoreSslErrors();
0
1024}
never executed: end of block
0
1025-
1026void QNetworkReplyImpl::ignoreSslErrorsImplementation(const QList<QSslError> &errors)-
1027{-
1028 Q_D(QNetworkReplyImpl);-
1029 if (d->backend)
d->backendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1030 d->backend->ignoreSslErrors(errors);
never executed: d->backend->ignoreSslErrors(errors);
0
1031}
never executed: end of block
0
1032#endif // QT_NO_SSL-
1033-
1034/*!-
1035 \internal-
1036*/-
1037qint64 QNetworkReplyImpl::readData(char *data, qint64 maxlen)-
1038{-
1039 Q_D(QNetworkReplyImpl);-
1040-
1041 // Special case code if we have the "zero copy" download buffer-
1042 if (d->downloadBuffer) {
d->downloadBufferDescription
TRUEnever evaluated
FALSEevaluated 252 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
0-252
1043 qint64 maxAvail = qMin<qint64>(d->downloadBufferCurrentSize - d->downloadBufferReadPosition, maxlen);-
1044 if (maxAvail == 0)
maxAvail == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1045 return d->state == QNetworkReplyPrivate::Finished ? -1 : 0;
never executed: return d->state == QNetworkReplyPrivate::Finished ? -1 : 0;
0
1046 // FIXME what about "Aborted" state?-
1047 memcpy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail);-
1048 d->downloadBufferReadPosition += maxAvail;-
1049 return maxAvail;
never executed: return maxAvail;
0
1050 }-
1051-
1052-
1053 // FIXME what about "Aborted" state?-
1054 if (d->state == QNetworkReplyPrivate::Finished)
d->state == QN...vate::FinishedDescription
TRUEevaluated 109 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 143 times by 1 test
Evaluated by:
  • tst_QNetworkReply
109-143
1055 return -1;
executed 109 times by 2 tests: return -1;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
109
1056-
1057 d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite);-
1058 return 0;
executed 143 times by 1 test: return 0;
Executed by:
  • tst_QNetworkReply
143
1059}-
1060-
1061/*!-
1062 \internal Reimplemented for internal purposes-
1063*/-
1064bool QNetworkReplyImpl::event(QEvent *e)-
1065{-
1066 if (e->type() == QEvent::NetworkReplyUpdated) {
e->type() == Q...rkReplyUpdatedDescription
TRUEevaluated 718 times by 2 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
FALSEevaluated 273 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
273-718
1067 d_func()->handleNotifications();-
1068 return true;
executed 718 times by 2 tests: return true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkReply
718
1069 }-
1070-
1071 return QObject::event(e);
executed 273 times by 3 tests: return QObject::event(e);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager
  • tst_QNetworkReply
273
1072}-
1073-
1074/*-
1075 Migrates the backend of the QNetworkReply to a new network connection if required. Returns-
1076 true if the reply is migrated or it is not required; otherwise returns \c false.-
1077*/-
1078bool QNetworkReplyImplPrivate::migrateBackend()-
1079{-
1080 Q_Q(QNetworkReplyImpl);-
1081-
1082 // Network reply is already finished or aborted, don't need to migrate.-
1083 if (state == Finished || state == Aborted)
state == FinishedDescription
TRUEnever evaluated
FALSEnever evaluated
state == AbortedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1084 return true;
never executed: return true;
0
1085-
1086 // Request has outgoing data, not migrating.-
1087 if (outgoingData)
outgoingDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1088 return false;
never executed: return false;
0
1089-
1090 // Request is serviced from the cache, don't need to migrate.-
1091 if (copyDevice)
copyDeviceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1092 return true;
never executed: return true;
0
1093-
1094 // Backend does not support resuming download.-
1095 if (backend && !backend->canResume())
backendDescription
TRUEnever evaluated
FALSEnever evaluated
!backend->canResume()Description
TRUEnever evaluated
FALSEnever evaluated
0
1096 return false;
never executed: return false;
0
1097-
1098 state = QNetworkReplyPrivate::Reconnecting;-
1099-
1100 cookedHeaders.clear();-
1101 rawHeaders.clear();-
1102-
1103 preMigrationDownloaded = bytesDownloaded;-
1104-
1105 delete backend;-
1106 backend = manager->d_func()->findBackend(operation, request);-
1107-
1108 if (backend) {
backendDescription
TRUEnever evaluated
FALSEnever evaluated
0
1109 backend->setParent(q);-
1110 backend->reply = this;-
1111 backend->setResumeOffset(bytesDownloaded);-
1112 }
never executed: end of block
0
1113-
1114 QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);-
1115-
1116 return true;
never executed: return true;
0
1117}-
1118-
1119#ifndef QT_NO_BEARERMANAGEMENT-
1120QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,-
1121 const QNetworkRequest &req,-
1122 QNetworkAccessManager::Operation op)-
1123: QNetworkReply(parent)-
1124{-
1125 setRequest(req);-
1126 setUrl(req.url());-
1127 setOperation(op);-
1128-
1129 qRegisterMetaType<QNetworkReply::NetworkError>();-
1130-
1131 QString msg = QCoreApplication::translate("QNetworkAccessManager",-
1132 "Network access is disabled.");-
1133 setError(UnknownNetworkError, msg);-
1134-
1135 QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,-
1136 Q_ARG(QNetworkReply::NetworkError, UnknownNetworkError));-
1137 QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);-
1138}
never executed: end of block
0
1139-
1140QDisabledNetworkReply::~QDisabledNetworkReply()-
1141{-
1142}-
1143#endif-
1144-
1145QT_END_NAMESPACE-
1146-
1147#include "moc_qnetworkreplyimpl_p.cpp"-
1148-
Source codeSwitch to Preprocessed file

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