access/qnetworkreplyimpl.cpp

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

Generated by Squish Coco Non-Commercial