Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() | - |
6 | : backend(0), outgoingData(0), | - |
7 | copyDevice(0), | - |
8 | cacheEnabled(false), cacheSaveDevice(0), | - |
9 | notificationHandlingPaused(false), | - |
10 | bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1), | - |
11 | httpStatusCode(0), | - |
12 | state(Idle) | - |
13 | , downloadBufferReadPosition(0) | - |
14 | , downloadBufferCurrentSize(0) | - |
15 | , downloadBufferMaximumSize(0) | - |
16 | , downloadBuffer(0) | - |
17 | { | - |
18 | } executed: } Execution Count:102 | 102 |
19 | | - |
20 | void QNetworkReplyImplPrivate::_q_startOperation() | - |
21 | { | - |
22 | QNetworkReplyImpl * const q = q_func(); | - |
23 | | - |
24 | | - |
25 | if (state == Working || state == Finished) { partially evaluated: state == Working no Evaluation Count:0 | yes Evaluation Count:102 |
partially evaluated: state == Finished no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
26 | QMessageLogger("access/qnetworkreplyimpl.cpp", 78, __PRETTY_FUNCTION__).debug("QNetworkReplyImpl::_q_startOperation was called more than once"); | - |
27 | return; | 0 |
28 | } | - |
29 | state = Working; | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | if (!backend) { evaluated: !backend yes Evaluation Count:4 | yes Evaluation Count:98 |
| 4-98 |
35 | error(QNetworkReplyImpl::ProtocolUnknownError, | - |
36 | QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); | - |
37 | finished(); | - |
38 | return; executed: return; Execution Count:4 | 4 |
39 | } | - |
40 | | - |
41 | | - |
42 | | - |
43 | QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession()); | - |
44 | QVariant isBackground = backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false)); | - |
45 | if (isBackground.toBool() && session && session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy)) { partially evaluated: isBackground.toBool() no Evaluation Count:0 | yes Evaluation Count:98 |
never evaluated: session->usagePolicies().testFlag(QNetworkSession::NoBackgroundTrafficPolicy) | 0-98 |
46 | error(QNetworkReply::BackgroundRequestNotAllowedError, | - |
47 | QCoreApplication::translate("QNetworkReply", "Background request not allowed.")); | - |
48 | finished(); | - |
49 | return; | 0 |
50 | } | - |
51 | | - |
52 | | - |
53 | if (!backend->start()) { partially evaluated: !backend->start() no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | state = WaitingForSession; | - |
59 | | - |
60 | if (session) { | 0 |
61 | QObject::connect(session.data(), "2""error(QNetworkSession::SessionError)", | - |
62 | q, "1""_q_networkSessionFailed()"); | - |
63 | | - |
64 | if (!session->isOpen()) { never evaluated: !session->isOpen() | 0 |
65 | session->setSessionProperty(QString::fromUtf8("" "ConnectInBackground" "", sizeof("ConnectInBackground") - 1), isBackground); | - |
66 | session->open(); | - |
67 | } | 0 |
68 | } else { | 0 |
69 | QMessageLogger("access/qnetworkreplyimpl.cpp", 121, __PRETTY_FUNCTION__).warning("Backend is waiting for QNetworkSession to connect, but there is none!"); | - |
70 | state = Working; | - |
71 | error(QNetworkReplyImpl::NetworkSessionFailedError, | - |
72 | QCoreApplication::translate("QNetworkReply", "Network session error.")); | - |
73 | finished(); | - |
74 | } | 0 |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | return; | 0 |
83 | } | - |
84 | | - |
85 | | - |
86 | if (session) { partially evaluated: session no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
87 | | - |
88 | QObject::connect(session.data(), "2""usagePoliciesChanged(QNetworkSession::UsagePolicies)", | - |
89 | q, "1""_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies)"); | - |
90 | } | 0 |
91 | | - |
92 | | - |
93 | | - |
94 | downloadProgressSignalChoke.start(); | - |
95 | uploadProgressSignalChoke.invalidate(); | - |
96 | | - |
97 | if (backend && backend->isSynchronous()) { partially evaluated: backend yes Evaluation Count:98 | no Evaluation Count:0 |
partially evaluated: backend->isSynchronous() no Evaluation Count:0 | yes Evaluation Count:98 |
| 0-98 |
98 | state = Finished; | - |
99 | q_func()->setFinished(true); | - |
100 | } else { | 0 |
101 | if (state != Finished) { evaluated: state != Finished yes Evaluation Count:81 | yes Evaluation Count:17 |
| 17-81 |
102 | if (operation == QNetworkAccessManager::GetOperation) evaluated: operation == QNetworkAccessManager::GetOperation yes Evaluation Count:31 | yes Evaluation Count:50 |
| 31-50 |
103 | pendingNotifications.append(NotifyDownstreamReadyWrite); executed: pendingNotifications.append(NotifyDownstreamReadyWrite); Execution Count:31 | 31 |
104 | | - |
105 | handleNotifications(); | - |
106 | } executed: } Execution Count:81 | 81 |
107 | } executed: } Execution Count:98 | 98 |
108 | } | - |
109 | | - |
110 | void QNetworkReplyImplPrivate::_q_copyReadyRead() | - |
111 | { | - |
112 | QNetworkReplyImpl * const q = q_func(); | - |
113 | if (state != Working) partially evaluated: state != Working no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
114 | return; | 0 |
115 | if (!copyDevice || !q->isOpen()) partially evaluated: !copyDevice no Evaluation Count:0 | yes Evaluation Count:9 |
partially evaluated: !q->isOpen() no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
116 | return; | 0 |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | for(;;) { | - |
123 | qint64 bytesToRead = nextDownstreamBlockSize(); | - |
124 | if (bytesToRead == 0) partially evaluated: bytesToRead == 0 no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
125 | | - |
126 | break; | 0 |
127 | | - |
128 | bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable()); | - |
129 | QByteArray byteData; | - |
130 | byteData.resize(bytesToRead); | - |
131 | qint64 bytesActuallyRead = copyDevice->read(byteData.data(), byteData.size()); | - |
132 | if (bytesActuallyRead == -1) { partially evaluated: bytesActuallyRead == -1 no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
133 | byteData.clear(); | - |
134 | backendNotify(NotifyCopyFinished); | - |
135 | break; | 0 |
136 | } | - |
137 | | - |
138 | byteData.resize(bytesActuallyRead); | - |
139 | readBuffer.append(byteData); | - |
140 | | - |
141 | if (!copyDevice->isSequential() && copyDevice->atEnd()) { partially evaluated: !copyDevice->isSequential() yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: copyDevice->atEnd() yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
142 | backendNotify(NotifyCopyFinished); | - |
143 | bytesDownloaded += bytesActuallyRead; | - |
144 | break; executed: break; Execution Count:9 | 9 |
145 | } | - |
146 | | - |
147 | bytesDownloaded += bytesActuallyRead; | - |
148 | } | 0 |
149 | | - |
150 | if (bytesDownloaded == lastBytesDownloaded) { partially evaluated: bytesDownloaded == lastBytesDownloaded no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
151 | | - |
152 | return; | 0 |
153 | } | - |
154 | | - |
155 | lastBytesDownloaded = bytesDownloaded; | - |
156 | QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); | - |
157 | if (preMigrationDownloaded != static_cast<long long>(-1LL)) partially evaluated: preMigrationDownloaded != static_cast<long long>(-1LL) no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
158 | totalSize = totalSize.toLongLong() + preMigrationDownloaded; never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded; | 0 |
159 | pauseNotificationHandling(); | - |
160 | | - |
161 | | - |
162 | q->readyRead(); | - |
163 | if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval yes Evaluation Count:5 | yes Evaluation Count:4 |
| 4-5 |
164 | downloadProgressSignalChoke.restart(); | - |
165 | q->downloadProgress(bytesDownloaded, | - |
166 | totalSize.isNull() ? static_cast<long long>(-1LL) : totalSize.toLongLong()); | - |
167 | } executed: } Execution Count:5 | 5 |
168 | resumeNotificationHandling(); | - |
169 | } executed: } Execution Count:9 | 9 |
170 | | - |
171 | void QNetworkReplyImplPrivate::_q_copyReadChannelFinished() | - |
172 | { | - |
173 | _q_copyReadyRead(); | - |
174 | } | 0 |
175 | | - |
176 | void QNetworkReplyImplPrivate::_q_bufferOutgoingDataFinished() | - |
177 | { | - |
178 | QNetworkReplyImpl * const q = q_func(); | - |
179 | | - |
180 | | - |
181 | | - |
182 | if (state != Buffering) never evaluated: state != Buffering | 0 |
183 | return; | 0 |
184 | | - |
185 | | - |
186 | QObject::disconnect(outgoingData, "2""readyRead()", q, "1""_q_bufferOutgoingData()"); | - |
187 | QObject::disconnect(outgoingData, "2""readChannelFinished()", q, "1""_q_bufferOutgoingDataFinished()"); | - |
188 | | - |
189 | | - |
190 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
191 | } | 0 |
192 | | - |
193 | void QNetworkReplyImplPrivate::_q_bufferOutgoingData() | - |
194 | { | - |
195 | QNetworkReplyImpl * const q = q_func(); | - |
196 | | - |
197 | if (!outgoingDataBuffer) { never evaluated: !outgoingDataBuffer | 0 |
198 | | - |
199 | outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer()); | - |
200 | | - |
201 | QObject::connect(outgoingData, "2""readyRead()", q, "1""_q_bufferOutgoingData()"); | - |
202 | QObject::connect(outgoingData, "2""readChannelFinished()", q, "1""_q_bufferOutgoingDataFinished()"); | - |
203 | } | 0 |
204 | | - |
205 | qint64 bytesBuffered = 0; | - |
206 | qint64 bytesToBuffer = 0; | - |
207 | | - |
208 | | - |
209 | for(;;) { | - |
210 | bytesToBuffer = outgoingData->bytesAvailable(); | - |
211 | | - |
212 | if (bytesToBuffer <= 0) never evaluated: bytesToBuffer <= 0 | 0 |
213 | bytesToBuffer = 2*1024; never executed: bytesToBuffer = 2*1024; | 0 |
214 | | - |
215 | char *dst = outgoingDataBuffer->reserve(bytesToBuffer); | - |
216 | bytesBuffered = outgoingData->read(dst, bytesToBuffer); | - |
217 | | - |
218 | if (bytesBuffered == -1) { never evaluated: bytesBuffered == -1 | 0 |
219 | | - |
220 | outgoingDataBuffer->chop(bytesToBuffer); | - |
221 | | - |
222 | _q_bufferOutgoingDataFinished(); | - |
223 | break; | 0 |
224 | } else if (bytesBuffered == 0) { never evaluated: bytesBuffered == 0 | 0 |
225 | | - |
226 | outgoingDataBuffer->chop(bytesToBuffer); | - |
227 | | - |
228 | break; | 0 |
229 | } else { | - |
230 | | - |
231 | outgoingDataBuffer->chop(bytesToBuffer - bytesBuffered); | - |
232 | } | 0 |
233 | } | - |
234 | } | 0 |
235 | | - |
236 | | - |
237 | void QNetworkReplyImplPrivate::_q_networkSessionConnected() | - |
238 | { | - |
239 | QNetworkReplyImpl * const q = q_func(); | - |
240 | | - |
241 | if (manager.isNull()) never evaluated: manager.isNull() | 0 |
242 | return; | 0 |
243 | | - |
244 | QSharedPointer<QNetworkSession> session = manager->d_func()->getNetworkSession(); | - |
245 | if (!session) never evaluated: !session | 0 |
246 | return; | 0 |
247 | | - |
248 | if (session->state() != QNetworkSession::Connected) never evaluated: session->state() != QNetworkSession::Connected | 0 |
249 | return; | 0 |
250 | | - |
251 | switch (state) { | - |
252 | case QNetworkReplyImplPrivate::Buffering: | - |
253 | case QNetworkReplyImplPrivate::Working: | - |
254 | case QNetworkReplyImplPrivate::Reconnecting: | - |
255 | | - |
256 | migrateBackend(); | - |
257 | break; | 0 |
258 | case QNetworkReplyImplPrivate::WaitingForSession: | - |
259 | | - |
260 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
261 | break; | 0 |
262 | default: | - |
263 | ; | - |
264 | } | 0 |
265 | } | 0 |
266 | | - |
267 | void QNetworkReplyImplPrivate::_q_networkSessionFailed() | - |
268 | { | - |
269 | | - |
270 | if (state == WaitingForSession || state == Working) { never evaluated: state == WaitingForSession never evaluated: state == Working | 0 |
271 | state = Working; | - |
272 | QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession()); | - |
273 | QString errorStr; | - |
274 | if (session) | 0 |
275 | errorStr = session->errorString(); never executed: errorStr = session->errorString(); | 0 |
276 | else | - |
277 | errorStr = QCoreApplication::translate("QNetworkReply", "Network session error."); never executed: errorStr = QCoreApplication::translate("QNetworkReply", "Network session error."); | 0 |
278 | error(QNetworkReplyImpl::NetworkSessionFailedError, errorStr); | - |
279 | finished(); | - |
280 | } | 0 |
281 | } | 0 |
282 | | - |
283 | void QNetworkReplyImplPrivate::_q_networkSessionUsagePoliciesChanged(QNetworkSession::UsagePolicies newPolicies) | - |
284 | { | - |
285 | if (backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute).toBool()) { never evaluated: backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute).toBool() | 0 |
286 | if (newPolicies & QNetworkSession::NoBackgroundTrafficPolicy) { never evaluated: newPolicies & QNetworkSession::NoBackgroundTrafficPolicy | 0 |
287 | | - |
288 | if (state == WaitingForSession || state == Working) { never evaluated: state == WaitingForSession never evaluated: state == Working | 0 |
289 | state = Working; | - |
290 | error(QNetworkReply::BackgroundRequestNotAllowedError, | - |
291 | QCoreApplication::translate("QNetworkReply", "Background request not allowed.")); | - |
292 | finished(); | - |
293 | } | 0 |
294 | | - |
295 | } | 0 |
296 | } | 0 |
297 | } | 0 |
298 | | - |
299 | | - |
300 | void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req, | - |
301 | QIODevice *data) | - |
302 | { | - |
303 | QNetworkReplyImpl * const q = q_func(); | - |
304 | | - |
305 | outgoingData = data; | - |
306 | request = req; | - |
307 | url = request.url(); | - |
308 | operation = op; | - |
309 | | - |
310 | q->QIODevice::open(QIODevice::ReadOnly); | - |
311 | | - |
312 | | - |
313 | QVariant synchronousHttpAttribute = req.attribute( | - |
314 | static_cast<QNetworkRequest::Attribute>(QNetworkRequest::SynchronousRequestAttribute)); | - |
315 | | - |
316 | | - |
317 | if (synchronousHttpAttribute.toBool() && outgoingData) { partially evaluated: synchronousHttpAttribute.toBool() no Evaluation Count:0 | yes Evaluation Count:102 |
never evaluated: outgoingData | 0-102 |
318 | outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer()); | - |
319 | qint64 previousDataSize = 0; | - |
320 | do { | - |
321 | previousDataSize = outgoingDataBuffer->size(); | - |
322 | outgoingDataBuffer->append(outgoingData->readAll()); | - |
323 | } while (outgoingDataBuffer->size() != previousDataSize); never evaluated: outgoingDataBuffer->size() != previousDataSize | 0 |
324 | } | 0 |
325 | | - |
326 | if (backend) evaluated: backend yes Evaluation Count:98 | yes Evaluation Count:4 |
| 4-98 |
327 | backend->setSynchronous(synchronousHttpAttribute.toBool()); executed: backend->setSynchronous(synchronousHttpAttribute.toBool()); Execution Count:98 | 98 |
328 | | - |
329 | | - |
330 | if (outgoingData && backend && !backend->isSynchronous()) { evaluated: outgoingData yes Evaluation Count:50 | yes Evaluation Count:52 |
partially evaluated: backend yes Evaluation Count:50 | no Evaluation Count:0 |
partially evaluated: !backend->isSynchronous() yes Evaluation Count:50 | no Evaluation Count:0 |
| 0-52 |
331 | | - |
332 | | - |
333 | if (!backend->needsResetableUploadData() || !outgoingData->isSequential()) { partially evaluated: !backend->needsResetableUploadData() yes Evaluation Count:50 | no Evaluation Count:0 |
never evaluated: !outgoingData->isSequential() | 0-50 |
334 | | - |
335 | | - |
336 | | - |
337 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
338 | } else { executed: } Execution Count:50 | 50 |
339 | bool bufferingDisallowed = | - |
340 | req.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute, | - |
341 | false).toBool(); | - |
342 | | - |
343 | if (bufferingDisallowed) { never evaluated: bufferingDisallowed | 0 |
344 | | - |
345 | | - |
346 | if (req.header(QNetworkRequest::ContentLengthHeader).isValid()) { never evaluated: req.header(QNetworkRequest::ContentLengthHeader).isValid() | 0 |
347 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
348 | } else { | 0 |
349 | state = Buffering; | - |
350 | QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection); | - |
351 | } | 0 |
352 | } else { | - |
353 | | - |
354 | state = Buffering; | - |
355 | QMetaObject::invokeMethod(q, "_q_bufferOutgoingData", Qt::QueuedConnection); | - |
356 | } | 0 |
357 | } | - |
358 | } else { | - |
359 | | - |
360 | | - |
361 | | - |
362 | if (backend && backend->isSynchronous()) { evaluated: backend yes Evaluation Count:48 | yes Evaluation Count:4 |
partially evaluated: backend->isSynchronous() no Evaluation Count:0 | yes Evaluation Count:48 |
| 0-48 |
363 | _q_startOperation(); | - |
364 | } else { | 0 |
365 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
366 | } executed: } Execution Count:52 | 52 |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | } | - |
374 | } | - |
375 | | - |
376 | void QNetworkReplyImplPrivate::backendNotify(InternalNotifications notification) | - |
377 | { | - |
378 | QNetworkReplyImpl * const q = q_func(); | - |
379 | if (!pendingNotifications.contains(notification)) evaluated: !pendingNotifications.contains(notification) yes Evaluation Count:823 | yes Evaluation Count:689 |
| 689-823 |
380 | pendingNotifications.enqueue(notification); executed: pendingNotifications.enqueue(notification); Execution Count:823 | 823 |
381 | | - |
382 | if (pendingNotifications.size() == 1) partially evaluated: pendingNotifications.size() == 1 yes Evaluation Count:1512 | no Evaluation Count:0 |
| 0-1512 |
383 | QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated)); executed: QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated)); Execution Count:1512 | 1512 |
384 | } executed: } Execution Count:1512 | 1512 |
385 | | - |
386 | void QNetworkReplyImplPrivate::handleNotifications() | - |
387 | { | - |
388 | if (notificationHandlingPaused) partially evaluated: notificationHandlingPaused no Evaluation Count:0 | yes Evaluation Count:1652 |
| 0-1652 |
389 | return; | 0 |
390 | | - |
391 | NotificationQueue current = pendingNotifications; | - |
392 | pendingNotifications.clear(); | - |
393 | | - |
394 | if (state != Working) evaluated: state != Working yes Evaluation Count:308 | yes Evaluation Count:1344 |
| 308-1344 |
395 | return; executed: return; Execution Count:308 | 308 |
396 | | - |
397 | while (state == Working && !current.isEmpty()) { evaluated: state == Working yes Evaluation Count:2158 | yes Evaluation Count:4 |
evaluated: !current.isEmpty() yes Evaluation Count:818 | yes Evaluation Count:1340 |
| 4-2158 |
398 | InternalNotifications notification = current.dequeue(); | - |
399 | switch (notification) { | - |
400 | case NotifyDownstreamReadyWrite: | - |
401 | if (copyDevice) partially evaluated: copyDevice no Evaluation Count:0 | yes Evaluation Count:818 |
| 0-818 |
402 | _q_copyReadyRead(); never executed: _q_copyReadyRead(); | 0 |
403 | else | - |
404 | backend->downstreamReadyWrite(); executed: backend->downstreamReadyWrite(); Execution Count:818 | 818 |
405 | break; executed: break; Execution Count:818 | 818 |
406 | | - |
407 | case NotifyCloseDownstreamChannel: | - |
408 | backend->closeDownstreamChannel(); | - |
409 | break; | 0 |
410 | | - |
411 | case NotifyCopyFinished: { | - |
412 | QIODevice *dev = copyDevice; | - |
413 | copyDevice = 0; | - |
414 | backend->copyFinished(dev); | - |
415 | break; | 0 |
416 | } | - |
417 | } | - |
418 | } executed: } Execution Count:818 | 818 |
419 | } executed: } Execution Count:1344 | 1344 |
420 | | - |
421 | | - |
422 | | - |
423 | void QNetworkReplyImplPrivate::pauseNotificationHandling() | - |
424 | { | - |
425 | notificationHandlingPaused = true; | - |
426 | } executed: } Execution Count:1761 | 1761 |
427 | | - |
428 | | - |
429 | void QNetworkReplyImplPrivate::resumeNotificationHandling() | - |
430 | { | - |
431 | QNetworkReplyImpl * const q = q_func(); | - |
432 | notificationHandlingPaused = false; | - |
433 | if (pendingNotifications.size() >= 1) evaluated: pendingNotifications.size() >= 1 yes Evaluation Count:293 | yes Evaluation Count:1468 |
| 293-1468 |
434 | QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated)); executed: QCoreApplication::postEvent(q, new QEvent(QEvent::NetworkReplyUpdated)); Execution Count:293 | 293 |
435 | } executed: } Execution Count:1761 | 1761 |
436 | | - |
437 | QAbstractNetworkCache *QNetworkReplyImplPrivate::networkCache() const | - |
438 | { | - |
439 | if (!backend) partially evaluated: !backend no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
440 | return 0; never executed: return 0; | 0 |
441 | return backend->networkCache(); executed: return backend->networkCache(); Execution Count:22 | 22 |
442 | } | - |
443 | | - |
444 | void QNetworkReplyImplPrivate::createCache() | - |
445 | { | - |
446 | | - |
447 | if (!networkCache() partially evaluated: !networkCache() yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
448 | || !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool()) never evaluated: !request.attribute(QNetworkRequest::CacheSaveControlAttribute, true).toBool() | 0 |
449 | return; executed: return; Execution Count:22 | 22 |
450 | cacheEnabled = true; | - |
451 | } | 0 |
452 | | - |
453 | bool QNetworkReplyImplPrivate::isCachingEnabled() const | - |
454 | { | - |
455 | return (cacheEnabled && networkCache() != 0); executed: return (cacheEnabled && networkCache() != 0); Execution Count:102 | 102 |
456 | } | - |
457 | | - |
458 | void QNetworkReplyImplPrivate::setCachingEnabled(bool enable) | - |
459 | { | - |
460 | if (!enable && !cacheEnabled) evaluated: !enable yes Evaluation Count:13 | yes Evaluation Count:22 |
partially evaluated: !cacheEnabled yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-22 |
461 | return; executed: return; Execution Count:13 | 13 |
462 | if (enable && cacheEnabled) partially evaluated: enable yes Evaluation Count:22 | no Evaluation Count:0 |
partially evaluated: cacheEnabled no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
463 | return; | 0 |
464 | | - |
465 | if (enable) { partially evaluated: enable yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
466 | if (bytesDownloaded) { partially evaluated: bytesDownloaded no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
467 | | - |
468 | QMessageLogger("access/qnetworkreplyimpl.cpp", 520, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: backend error: caching was enabled after some bytes had been written"); | - |
469 | return; | 0 |
470 | } | - |
471 | | - |
472 | createCache(); | - |
473 | } else { executed: } Execution Count:22 | 22 |
474 | | - |
475 | | - |
476 | QMessageLogger("access/qnetworkreplyimpl.cpp", 528, __PRETTY_FUNCTION__).debug("QNetworkReplyImpl: setCachingEnabled(true) called after setCachingEnabled(false) -- " | - |
477 | "backend %s probably needs to be fixed", | - |
478 | backend->metaObject()->className()); | - |
479 | networkCache()->remove(url); | - |
480 | cacheSaveDevice = 0; | - |
481 | cacheEnabled = false; | - |
482 | } | 0 |
483 | } | - |
484 | | - |
485 | void QNetworkReplyImplPrivate::completeCacheSave() | - |
486 | { | - |
487 | if (cacheEnabled && errorCode != QNetworkReplyImpl::NoError) { partially evaluated: cacheEnabled no Evaluation Count:0 | yes Evaluation Count:100 |
never evaluated: errorCode != QNetworkReplyImpl::NoError | 0-100 |
488 | networkCache()->remove(url); | - |
489 | } else if (cacheEnabled && cacheSaveDevice) { partially evaluated: cacheEnabled no Evaluation Count:0 | yes Evaluation Count:100 |
never evaluated: cacheSaveDevice | 0-100 |
490 | networkCache()->insert(cacheSaveDevice); | - |
491 | } | 0 |
492 | cacheSaveDevice = 0; | - |
493 | cacheEnabled = false; | - |
494 | } executed: } Execution Count:100 | 100 |
495 | | - |
496 | void QNetworkReplyImplPrivate::emitUploadProgress(qint64 bytesSent, qint64 bytesTotal) | - |
497 | { | - |
498 | QNetworkReplyImpl * const q = q_func(); | - |
499 | bytesUploaded = bytesSent; | - |
500 | | - |
501 | | - |
502 | if (uploadProgressSignalChoke.isValid()) { evaluated: uploadProgressSignalChoke.isValid() yes Evaluation Count:850 | yes Evaluation Count:46 |
| 46-850 |
503 | if (bytesSent != bytesTotal && uploadProgressSignalChoke.elapsed() < progressSignalInterval) { evaluated: bytesSent != bytesTotal yes Evaluation Count:272 | yes Evaluation Count:578 |
partially evaluated: uploadProgressSignalChoke.elapsed() < progressSignalInterval yes Evaluation Count:272 | no Evaluation Count:0 |
| 0-578 |
504 | return; executed: return; Execution Count:272 | 272 |
505 | } | - |
506 | uploadProgressSignalChoke.restart(); | - |
507 | } else { executed: } Execution Count:578 | 578 |
508 | uploadProgressSignalChoke.start(); | - |
509 | } executed: } Execution Count:46 | 46 |
510 | | - |
511 | pauseNotificationHandling(); | - |
512 | q->uploadProgress(bytesSent, bytesTotal); | - |
513 | resumeNotificationHandling(); | - |
514 | } executed: } Execution Count:624 | 624 |
515 | | - |
516 | | - |
517 | qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const | - |
518 | { | - |
519 | enum { DesiredBufferSize = 32 * 1024 }; | - |
520 | if (readBufferMaxSize == 0) partially evaluated: readBufferMaxSize == 0 yes Evaluation Count:869 | no Evaluation Count:0 |
| 0-869 |
521 | return DesiredBufferSize; executed: return DesiredBufferSize; Execution Count:869 | 869 |
522 | | - |
523 | return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount()); never executed: return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount()); | 0 |
524 | } | - |
525 | | - |
526 | void QNetworkReplyImplPrivate::initCacheSaveDevice() | - |
527 | { | - |
528 | QNetworkReplyImpl * const q = q_func(); | - |
529 | | - |
530 | | - |
531 | | - |
532 | if (q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206) { never evaluated: q->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 206 | 0 |
533 | cacheEnabled = false; | - |
534 | return; | 0 |
535 | } | - |
536 | | - |
537 | | - |
538 | QNetworkCacheMetaData metaData; | - |
539 | metaData.setUrl(url); | - |
540 | metaData = backend->fetchCacheMetaData(metaData); | - |
541 | | - |
542 | | - |
543 | QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); | - |
544 | if (redirectionTarget.isValid()) { never evaluated: redirectionTarget.isValid() | 0 |
545 | QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); | - |
546 | attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); | - |
547 | metaData.setAttributes(attributes); | - |
548 | } | 0 |
549 | | - |
550 | cacheSaveDevice = networkCache()->prepare(metaData); | - |
551 | | - |
552 | if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { never evaluated: !cacheSaveDevice never evaluated: cacheSaveDevice never evaluated: !cacheSaveDevice->isOpen() | 0 |
553 | if (cacheSaveDevice && !cacheSaveDevice->isOpen()) never evaluated: cacheSaveDevice never evaluated: !cacheSaveDevice->isOpen() | 0 |
554 | QMessageLogger("access/qnetworkreplyimpl.cpp", 606, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: network cache returned a device that is not open -- " | 0 |
555 | "class %s probably needs to be fixed", | 0 |
556 | 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 |
557 | | - |
558 | networkCache()->remove(url); | - |
559 | cacheSaveDevice = 0; | - |
560 | cacheEnabled = false; | - |
561 | } | 0 |
562 | } | 0 |
563 | | - |
564 | | - |
565 | | - |
566 | void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) | - |
567 | { | - |
568 | QNetworkReplyImpl * const q = q_func(); | - |
569 | if (!q->isOpen()) partially evaluated: !q->isOpen() no Evaluation Count:0 | yes Evaluation Count:822 |
| 0-822 |
570 | return; | 0 |
571 | | - |
572 | if (cacheEnabled && !cacheSaveDevice) { partially evaluated: cacheEnabled no Evaluation Count:0 | yes Evaluation Count:822 |
never evaluated: !cacheSaveDevice | 0-822 |
573 | initCacheSaveDevice(); | - |
574 | } | 0 |
575 | | - |
576 | qint64 bytesWritten = 0; | - |
577 | for (int i = 0; i < data.bufferCount(); i++) { evaluated: i < data.bufferCount() yes Evaluation Count:822 | yes Evaluation Count:822 |
| 822 |
578 | QByteArray const &item = data[i]; | - |
579 | | - |
580 | if (cacheSaveDevice) partially evaluated: cacheSaveDevice no Evaluation Count:0 | yes Evaluation Count:822 |
| 0-822 |
581 | cacheSaveDevice->write(item.constData(), item.size()); never executed: cacheSaveDevice->write(item.constData(), item.size()); | 0 |
582 | readBuffer.append(item); | - |
583 | | - |
584 | bytesWritten += item.size(); | - |
585 | } executed: } Execution Count:822 | 822 |
586 | data.clear(); | - |
587 | | - |
588 | bytesDownloaded += bytesWritten; | - |
589 | lastBytesDownloaded = bytesDownloaded; | - |
590 | | - |
591 | appendDownstreamDataSignalEmissions(); | - |
592 | } executed: } Execution Count:822 | 822 |
593 | | - |
594 | void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions() | - |
595 | { | - |
596 | QNetworkReplyImpl * const q = q_func(); | - |
597 | | - |
598 | QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); | - |
599 | if (preMigrationDownloaded != static_cast<long long>(-1LL)) partially evaluated: preMigrationDownloaded != static_cast<long long>(-1LL) no Evaluation Count:0 | yes Evaluation Count:822 |
| 0-822 |
600 | totalSize = totalSize.toLongLong() + preMigrationDownloaded; never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded; | 0 |
601 | pauseNotificationHandling(); | - |
602 | | - |
603 | | - |
604 | q->readyRead(); | - |
605 | | - |
606 | | - |
607 | if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval yes Evaluation Count:1 | yes Evaluation Count:821 |
| 1-821 |
608 | downloadProgressSignalChoke.restart(); | - |
609 | q->downloadProgress(bytesDownloaded, | - |
610 | totalSize.isNull() ? static_cast<long long>(-1LL) : totalSize.toLongLong()); | - |
611 | } executed: } Execution Count:1 | 1 |
612 | | - |
613 | resumeNotificationHandling(); | - |
614 | | - |
615 | if (nextDownstreamBlockSize() > 0) partially evaluated: nextDownstreamBlockSize() > 0 yes Evaluation Count:822 | no Evaluation Count:0 |
| 0-822 |
616 | backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); executed: backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); Execution Count:822 | 822 |
617 | } executed: } Execution Count:822 | 822 |
618 | | - |
619 | | - |
620 | void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data) | - |
621 | { | - |
622 | QNetworkReplyImpl * const q = q_func(); | - |
623 | if (!q->isOpen()) partially evaluated: !q->isOpen() no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
624 | return; | 0 |
625 | | - |
626 | | - |
627 | if (copyDevice) { partially evaluated: copyDevice no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
628 | QMessageLogger("access/qnetworkreplyimpl.cpp", 680, __PRETTY_FUNCTION__).critical("QNetworkReplyImpl: copy from QIODevice already in progress -- " | - |
629 | "backend probly needs to be fixed"); | - |
630 | return; | 0 |
631 | } | - |
632 | | - |
633 | copyDevice = data; | - |
634 | q->connect(copyDevice, "2""readyRead()", "1""_q_copyReadyRead()"); | - |
635 | q->connect(copyDevice, "2""readChannelFinished()", "1""_q_copyReadChannelFinished()"); | - |
636 | | - |
637 | | - |
638 | _q_copyReadyRead(); | - |
639 | } executed: } Execution Count:9 | 9 |
640 | | - |
641 | void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data) | - |
642 | { | - |
643 | (void)data; | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | QMessageLogger("access/qnetworkreplyimpl.cpp", 700, __PRETTY_FUNCTION__).fatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented"); | - |
649 | } | 0 |
650 | | - |
651 | static void downloadBufferDeleter(char *ptr) | - |
652 | { | - |
653 | delete[] ptr; | - |
654 | } | 0 |
655 | | - |
656 | char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size) | - |
657 | { | - |
658 | QNetworkReplyImpl * const q = q_func(); | - |
659 | | - |
660 | if (!downloadBuffer) { never evaluated: !downloadBuffer | 0 |
661 | | - |
662 | | - |
663 | QVariant bufferAllocationPolicy = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute); | - |
664 | if (bufferAllocationPolicy.isValid() && bufferAllocationPolicy.toLongLong() >= size) { never evaluated: bufferAllocationPolicy.isValid() never evaluated: bufferAllocationPolicy.toLongLong() >= size | 0 |
665 | downloadBufferCurrentSize = 0; | - |
666 | downloadBufferMaximumSize = size; | - |
667 | downloadBuffer = new char[downloadBufferMaximumSize]; | - |
668 | downloadBufferPointer = QSharedPointer<char>(downloadBuffer, downloadBufferDeleter); | - |
669 | | - |
670 | q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer)); | - |
671 | } | 0 |
672 | } | 0 |
673 | | - |
674 | return downloadBuffer; never executed: return downloadBuffer; | 0 |
675 | } | - |
676 | | - |
677 | void QNetworkReplyImplPrivate::setDownloadBuffer(QSharedPointer<char> sp, qint64 size) | - |
678 | { | - |
679 | QNetworkReplyImpl * const q = q_func(); | - |
680 | | - |
681 | downloadBufferPointer = sp; | - |
682 | downloadBuffer = downloadBufferPointer.data(); | - |
683 | downloadBufferCurrentSize = 0; | - |
684 | downloadBufferMaximumSize = size; | - |
685 | q->setAttribute(QNetworkRequest::DownloadBufferAttribute, QVariant::fromValue<QSharedPointer<char> > (downloadBufferPointer)); | - |
686 | } | 0 |
687 | | - |
688 | | - |
689 | void QNetworkReplyImplPrivate::appendDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal) | - |
690 | { | - |
691 | QNetworkReplyImpl * const q = q_func(); | - |
692 | if (!q->isOpen()) never evaluated: !q->isOpen() | 0 |
693 | return; | 0 |
694 | | - |
695 | if (cacheEnabled && !cacheSaveDevice) never evaluated: cacheEnabled never evaluated: !cacheSaveDevice | 0 |
696 | initCacheSaveDevice(); never executed: initCacheSaveDevice(); | 0 |
697 | | - |
698 | if (cacheSaveDevice && bytesReceived == bytesTotal) { never evaluated: cacheSaveDevice never evaluated: bytesReceived == bytesTotal | 0 |
699 | | - |
700 | | - |
701 | | - |
702 | | - |
703 | | - |
704 | cacheSaveDevice->write(downloadBuffer, bytesTotal); | - |
705 | } | 0 |
706 | | - |
707 | bytesDownloaded = bytesReceived; | - |
708 | lastBytesDownloaded = bytesReceived; | - |
709 | | - |
710 | downloadBufferCurrentSize = bytesReceived; | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | if (bytesDownloaded > 0) never evaluated: bytesDownloaded > 0 | 0 |
716 | q->readyRead(); never executed: q->readyRead(); | 0 |
717 | if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) { never evaluated: downloadProgressSignalChoke.elapsed() >= progressSignalInterval | 0 |
718 | downloadProgressSignalChoke.restart(); | - |
719 | q->downloadProgress(bytesDownloaded, bytesTotal); | - |
720 | } | 0 |
721 | } | 0 |
722 | | - |
723 | void QNetworkReplyImplPrivate::finished() | - |
724 | { | - |
725 | QNetworkReplyImpl * const q = q_func(); | - |
726 | | - |
727 | if (state == Finished || state == Aborted || state == WaitingForSession) partially evaluated: state == Finished no Evaluation Count:0 | yes Evaluation Count:102 |
partially evaluated: state == Aborted no Evaluation Count:0 | yes Evaluation Count:102 |
partially evaluated: state == WaitingForSession no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
728 | return; | 0 |
729 | | - |
730 | pauseNotificationHandling(); | - |
731 | QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); | - |
732 | if (preMigrationDownloaded != static_cast<long long>(-1LL)) partially evaluated: preMigrationDownloaded != static_cast<long long>(-1LL) no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
733 | totalSize = totalSize.toLongLong() + preMigrationDownloaded; never executed: totalSize = totalSize.toLongLong() + preMigrationDownloaded; | 0 |
734 | | - |
735 | if (!manager.isNull()) { partially evaluated: !manager.isNull() yes Evaluation Count:102 | no Evaluation Count:0 |
| 0-102 |
736 | | - |
737 | QSharedPointer<QNetworkSession> session (manager->d_func()->getNetworkSession()); | - |
738 | if (session && session->state() == QNetworkSession::Roaming && partially evaluated: session no Evaluation Count:0 | yes Evaluation Count:102 |
never evaluated: session->state() == QNetworkSession::Roaming | 0-102 |
739 | state == Working && errorCode != QNetworkReply::OperationCanceledError) { never evaluated: state == Working never evaluated: errorCode != QNetworkReply::OperationCanceledError | 0 |
740 | | - |
741 | if (!totalSize.isNull()) { never evaluated: !totalSize.isNull() | 0 |
742 | if (bytesDownloaded != totalSize) { never evaluated: bytesDownloaded != totalSize | 0 |
743 | if (migrateBackend()) { never evaluated: migrateBackend() | 0 |
744 | | - |
745 | if (state == Reconnecting || state == WaitingForSession) { never evaluated: state == Reconnecting never evaluated: state == WaitingForSession | 0 |
746 | resumeNotificationHandling(); | - |
747 | return; | 0 |
748 | } | - |
749 | } else { | 0 |
750 | error(QNetworkReply::TemporaryNetworkFailureError, | - |
751 | QNetworkReply::tr("Temporary network failure.")); | - |
752 | } | 0 |
753 | } | - |
754 | } | 0 |
755 | } | 0 |
756 | | - |
757 | } executed: } Execution Count:102 | 102 |
758 | resumeNotificationHandling(); | - |
759 | | - |
760 | state = Finished; | - |
761 | q->setFinished(true); | - |
762 | | - |
763 | pendingNotifications.clear(); | - |
764 | | - |
765 | pauseNotificationHandling(); | - |
766 | if (totalSize.isNull() || totalSize == -1) { evaluated: totalSize.isNull() yes Evaluation Count:76 | yes Evaluation Count:26 |
partially evaluated: totalSize == -1 no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-76 |
767 | q->downloadProgress(bytesDownloaded, bytesDownloaded); | - |
768 | } else { executed: } Execution Count:76 | 76 |
769 | q->downloadProgress(bytesDownloaded, totalSize.toLongLong()); | - |
770 | } executed: } Execution Count:26 | 26 |
771 | | - |
772 | if (bytesUploaded == -1 && (outgoingData || outgoingDataBuffer)) evaluated: bytesUploaded == -1 yes Evaluation Count:56 | yes Evaluation Count:46 |
evaluated: outgoingData yes Evaluation Count:4 | yes Evaluation Count:52 |
partially evaluated: outgoingDataBuffer no Evaluation Count:0 | yes Evaluation Count:52 |
| 0-56 |
773 | q->uploadProgress(0, 0); executed: q->uploadProgress(0, 0); Execution Count:4 | 4 |
774 | resumeNotificationHandling(); | - |
775 | | - |
776 | | - |
777 | if (totalSize.isNull() || totalSize == -1 || bytesDownloaded == totalSize) evaluated: totalSize.isNull() yes Evaluation Count:76 | yes Evaluation Count:26 |
partially evaluated: totalSize == -1 no Evaluation Count:0 | yes Evaluation Count:26 |
evaluated: bytesDownloaded == totalSize yes Evaluation Count:24 | yes Evaluation Count:2 |
| 0-76 |
778 | completeCacheSave(); executed: completeCacheSave(); Execution Count:100 | 100 |
779 | | - |
780 | | - |
781 | | - |
782 | | - |
783 | pauseNotificationHandling(); | - |
784 | q->readChannelFinished(); | - |
785 | q->finished(); | - |
786 | resumeNotificationHandling(); | - |
787 | } executed: } Execution Count:102 | 102 |
788 | | - |
789 | void QNetworkReplyImplPrivate::error(QNetworkReplyImpl::NetworkError code, const QString &errorMessage) | - |
790 | { | - |
791 | QNetworkReplyImpl * const q = q_func(); | - |
792 | | - |
793 | if (errorCode != QNetworkReply::NoError) { partially evaluated: errorCode != QNetworkReply::NoError no Evaluation Count:0 | yes Evaluation Count:19 |
| 0-19 |
794 | QMessageLogger("access/qnetworkreplyimpl.cpp", 846, __PRETTY_FUNCTION__).warning( "QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once."); | - |
795 | return; | 0 |
796 | } | - |
797 | | - |
798 | errorCode = code; | - |
799 | q->setErrorString(errorMessage); | - |
800 | | - |
801 | | - |
802 | | - |
803 | | - |
804 | q->error(code); | - |
805 | } executed: } Execution Count:19 | 19 |
806 | | - |
807 | void QNetworkReplyImplPrivate::metaDataChanged() | - |
808 | { | - |
809 | QNetworkReplyImpl * const q = q_func(); | - |
810 | | - |
811 | | - |
812 | if (cookedHeaders.contains(QNetworkRequest::SetCookieHeader) && !manager.isNull() partially evaluated: cookedHeaders.contains(QNetworkRequest::SetCookieHeader) no Evaluation Count:0 | yes Evaluation Count:46 |
never evaluated: !manager.isNull() | 0-46 |
813 | && (static_cast<QNetworkRequest::LoadControl> | 0 |
814 | (request.attribute(QNetworkRequest::CookieSaveControlAttribute, | 0 |
815 | QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic)) { never evaluated: (static_cast<QNetworkRequest::LoadControl> (request.attribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Automatic) | 0 |
816 | QList<QNetworkCookie> cookies = | - |
817 | qvariant_cast<QList<QNetworkCookie> >(cookedHeaders.value(QNetworkRequest::SetCookieHeader)); | - |
818 | QNetworkCookieJar *jar = manager->cookieJar(); | - |
819 | if (jar) | 0 |
820 | jar->setCookiesFromUrl(cookies, url); never executed: jar->setCookiesFromUrl(cookies, url); | 0 |
821 | } | 0 |
822 | q->metaDataChanged(); | - |
823 | } executed: } Execution Count:46 | 46 |
824 | | - |
825 | void QNetworkReplyImplPrivate::redirectionRequested(const QUrl &target) | - |
826 | { | - |
827 | attributes.insert(QNetworkRequest::RedirectionTargetAttribute, target); | - |
828 | } | 0 |
829 | | - |
830 | void QNetworkReplyImplPrivate::sslErrors(const QList<QSslError> &errors) | - |
831 | { | - |
832 | | - |
833 | QNetworkReplyImpl * const q = q_func(); | - |
834 | q->sslErrors(errors); | - |
835 | | - |
836 | | - |
837 | | - |
838 | } | 0 |
839 | | - |
840 | QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent) | - |
841 | : QNetworkReply(*new QNetworkReplyImplPrivate, parent) | - |
842 | { | - |
843 | } executed: } Execution Count:102 | 102 |
844 | | - |
845 | QNetworkReplyImpl::~QNetworkReplyImpl() | - |
846 | { | - |
847 | QNetworkReplyImplPrivate * const d = d_func(); | - |
848 | | - |
849 | | - |
850 | | - |
851 | | - |
852 | if (d->isCachingEnabled()) partially evaluated: d->isCachingEnabled() no Evaluation Count:0 | yes Evaluation Count:102 |
| 0-102 |
853 | d->networkCache()->remove(url()); never executed: d->networkCache()->remove(url()); | 0 |
854 | } executed: } Execution Count:102 | 102 |
855 | | - |
856 | void QNetworkReplyImpl::abort() | - |
857 | { | - |
858 | QNetworkReplyImplPrivate * const d = d_func(); | - |
859 | if (d->state == QNetworkReplyImplPrivate::Finished || d->state == QNetworkReplyImplPrivate::Aborted) never evaluated: d->state == QNetworkReplyImplPrivate::Finished never evaluated: d->state == QNetworkReplyImplPrivate::Aborted | 0 |
860 | return; | 0 |
861 | | - |
862 | | - |
863 | if (d->outgoingData) never evaluated: d->outgoingData | 0 |
864 | disconnect(d->outgoingData, 0, this, 0); never executed: disconnect(d->outgoingData, 0, this, 0); | 0 |
865 | if (d->copyDevice) never evaluated: d->copyDevice | 0 |
866 | disconnect(d->copyDevice, 0, this, 0); never executed: disconnect(d->copyDevice, 0, this, 0); | 0 |
867 | | - |
868 | QNetworkReply::close(); | - |
869 | | - |
870 | if (d->state != QNetworkReplyImplPrivate::Finished) { never evaluated: d->state != QNetworkReplyImplPrivate::Finished | 0 |
871 | | - |
872 | d->error(OperationCanceledError, tr("Operation canceled")); | - |
873 | if (d->state == QNetworkReplyImplPrivate::WaitingForSession) never evaluated: d->state == QNetworkReplyImplPrivate::WaitingForSession | 0 |
874 | d->state = QNetworkReplyImplPrivate::Working; never executed: d->state = QNetworkReplyImplPrivate::Working; | 0 |
875 | d->finished(); | - |
876 | } | 0 |
877 | d->state = QNetworkReplyImplPrivate::Aborted; | - |
878 | | - |
879 | | - |
880 | if (d->backend) { never evaluated: d->backend | 0 |
881 | d->backend->deleteLater(); | - |
882 | d->backend = 0; | - |
883 | } | 0 |
884 | } | 0 |
885 | | - |
886 | void QNetworkReplyImpl::close() | - |
887 | { | - |
888 | QNetworkReplyImplPrivate * const d = d_func(); | - |
889 | if (d->state == QNetworkReplyImplPrivate::Aborted || partially evaluated: d->state == QNetworkReplyImplPrivate::Aborted no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
890 | d->state == QNetworkReplyImplPrivate::Finished) evaluated: d->state == QNetworkReplyImplPrivate::Finished yes Evaluation Count:11 | yes Evaluation Count:1 |
| 1-11 |
891 | return; executed: return; Execution Count:11 | 11 |
892 | | - |
893 | | - |
894 | if (d->backend) partially evaluated: d->backend yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
895 | d->backend->closeDownstreamChannel(); executed: d->backend->closeDownstreamChannel(); Execution Count:1 | 1 |
896 | if (d->copyDevice) partially evaluated: d->copyDevice no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
897 | disconnect(d->copyDevice, 0, this, 0); never executed: disconnect(d->copyDevice, 0, this, 0); | 0 |
898 | | - |
899 | QNetworkReply::close(); | - |
900 | | - |
901 | | - |
902 | d->error(OperationCanceledError, tr("Operation canceled")); | - |
903 | d->finished(); | - |
904 | } executed: } Execution Count:1 | 1 |
905 | | - |
906 | bool QNetworkReplyImpl::canReadLine () const | - |
907 | { | - |
908 | const QNetworkReplyImplPrivate * const d = d_func(); | - |
909 | return QNetworkReply::canReadLine() || d->readBuffer.canReadLine(); never executed: return QNetworkReply::canReadLine() || d->readBuffer.canReadLine(); | 0 |
910 | } | - |
911 | | - |
912 | | - |
913 | | - |
914 | | - |
915 | | - |
916 | | - |
917 | | - |
918 | qint64 QNetworkReplyImpl::bytesAvailable() const | - |
919 | { | - |
920 | | - |
921 | const QNetworkReplyImplPrivate * const d = d_func(); | - |
922 | if (d->downloadBuffer) { partially evaluated: d->downloadBuffer no Evaluation Count:0 | yes Evaluation Count:510 |
| 0-510 |
923 | qint64 maxAvail = d->downloadBufferCurrentSize - d->downloadBufferReadPosition; | - |
924 | return QNetworkReply::bytesAvailable() + maxAvail; never executed: return QNetworkReply::bytesAvailable() + maxAvail; | 0 |
925 | } | - |
926 | | - |
927 | return QNetworkReply::bytesAvailable() + d_func()->readBuffer.byteAmount(); executed: return QNetworkReply::bytesAvailable() + d_func()->readBuffer.byteAmount(); Execution Count:510 | 510 |
928 | } | - |
929 | | - |
930 | void QNetworkReplyImpl::setReadBufferSize(qint64 size) | - |
931 | { | - |
932 | QNetworkReplyImplPrivate * const d = d_func(); | - |
933 | if (size > d->readBufferMaxSize && never evaluated: size > d->readBufferMaxSize | 0 |
934 | size > d->readBuffer.byteAmount()) never evaluated: size > d->readBuffer.byteAmount() | 0 |
935 | d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); never executed: d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); | 0 |
936 | | - |
937 | QNetworkReply::setReadBufferSize(size); | - |
938 | | - |
939 | if (d->backend) never evaluated: d->backend | 0 |
940 | d->backend->setDownstreamLimited(d->readBufferMaxSize > 0); never executed: d->backend->setDownstreamLimited(d->readBufferMaxSize > 0); | 0 |
941 | } | 0 |
942 | | - |
943 | | - |
944 | void QNetworkReplyImpl::sslConfigurationImplementation(QSslConfiguration &configuration) const | - |
945 | { | - |
946 | const QNetworkReplyImplPrivate * const d = d_func(); | - |
947 | if (d->backend) never evaluated: d->backend | 0 |
948 | d->backend->fetchSslConfiguration(configuration); never executed: d->backend->fetchSslConfiguration(configuration); | 0 |
949 | } | 0 |
950 | | - |
951 | void QNetworkReplyImpl::setSslConfigurationImplementation(const QSslConfiguration &config) | - |
952 | { | - |
953 | QNetworkReplyImplPrivate * const d = d_func(); | - |
954 | if (d->backend && !config.isNull()) evaluated: d->backend yes Evaluation Count:85 | yes Evaluation Count:4 |
partially evaluated: !config.isNull() yes Evaluation Count:85 | no Evaluation Count:0 |
| 0-85 |
955 | d->backend->setSslConfiguration(config); executed: d->backend->setSslConfiguration(config); Execution Count:85 | 85 |
956 | } executed: } Execution Count:89 | 89 |
957 | | - |
958 | void QNetworkReplyImpl::ignoreSslErrors() | - |
959 | { | - |
960 | QNetworkReplyImplPrivate * const d = d_func(); | - |
961 | if (d->backend) never evaluated: d->backend | 0 |
962 | d->backend->ignoreSslErrors(); never executed: d->backend->ignoreSslErrors(); | 0 |
963 | } | 0 |
964 | | - |
965 | void QNetworkReplyImpl::ignoreSslErrorsImplementation(const QList<QSslError> &errors) | - |
966 | { | - |
967 | QNetworkReplyImplPrivate * const d = d_func(); | - |
968 | if (d->backend) never evaluated: d->backend | 0 |
969 | d->backend->ignoreSslErrors(errors); never executed: d->backend->ignoreSslErrors(errors); | 0 |
970 | } | 0 |
971 | | - |
972 | | - |
973 | | - |
974 | | - |
975 | | - |
976 | qint64 QNetworkReplyImpl::readData(char *data, qint64 maxlen) | - |
977 | { | - |
978 | QNetworkReplyImplPrivate * const d = d_func(); | - |
979 | | - |
980 | | - |
981 | if (d->downloadBuffer) { partially evaluated: d->downloadBuffer no Evaluation Count:0 | yes Evaluation Count:1043 |
| 0-1043 |
982 | qint64 maxAvail = qMin<qint64>(d->downloadBufferCurrentSize - d->downloadBufferReadPosition, maxlen); | - |
983 | if (maxAvail == 0) never evaluated: maxAvail == 0 | 0 |
984 | return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; never executed: return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; | 0 |
985 | | - |
986 | memcpy(data, d->downloadBuffer + d->downloadBufferReadPosition, maxAvail); | - |
987 | d->downloadBufferReadPosition += maxAvail; | - |
988 | return maxAvail; never executed: return maxAvail; | 0 |
989 | } | - |
990 | | - |
991 | | - |
992 | if (d->readBuffer.isEmpty()) evaluated: d->readBuffer.isEmpty() yes Evaluation Count:362 | yes Evaluation Count:681 |
| 362-681 |
993 | return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; executed: return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; Execution Count:362 | 362 |
994 | | - |
995 | | - |
996 | d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); | - |
997 | if (maxlen == 1) { partially evaluated: maxlen == 1 no Evaluation Count:0 | yes Evaluation Count:681 |
| 0-681 |
998 | | - |
999 | *data = d->readBuffer.getChar(); | - |
1000 | return 1; never executed: return 1; | 0 |
1001 | } | - |
1002 | | - |
1003 | maxlen = qMin<qint64>(maxlen, d->readBuffer.byteAmount()); | - |
1004 | return d->readBuffer.read(data, maxlen); executed: return d->readBuffer.read(data, maxlen); Execution Count:681 | 681 |
1005 | } | - |
1006 | | - |
1007 | | - |
1008 | | - |
1009 | | - |
1010 | bool QNetworkReplyImpl::event(QEvent *e) | - |
1011 | { | - |
1012 | if (e->type() == QEvent::NetworkReplyUpdated) { evaluated: e->type() == QEvent::NetworkReplyUpdated yes Evaluation Count:1571 | yes Evaluation Count:222 |
| 222-1571 |
1013 | d_func()->handleNotifications(); | - |
1014 | return true; executed: return true; Execution Count:1571 | 1571 |
1015 | } | - |
1016 | | - |
1017 | return QObject::event(e); executed: return QObject::event(e); Execution Count:222 | 222 |
1018 | } | - |
1019 | | - |
1020 | | - |
1021 | | - |
1022 | | - |
1023 | | - |
1024 | bool QNetworkReplyImplPrivate::migrateBackend() | - |
1025 | { | - |
1026 | QNetworkReplyImpl * const q = q_func(); | - |
1027 | | - |
1028 | | - |
1029 | if (state == Finished || state == Aborted) never evaluated: state == Finished never evaluated: state == Aborted | 0 |
1030 | return true; never executed: return true; | 0 |
1031 | | - |
1032 | | - |
1033 | if (outgoingData) never evaluated: outgoingData | 0 |
1034 | return false; never executed: return false; | 0 |
1035 | | - |
1036 | | - |
1037 | if (copyDevice) never evaluated: copyDevice | 0 |
1038 | return true; never executed: return true; | 0 |
1039 | | - |
1040 | | - |
1041 | if (!backend->canResume()) never evaluated: !backend->canResume() | 0 |
1042 | return false; never executed: return false; | 0 |
1043 | | - |
1044 | state = QNetworkReplyImplPrivate::Reconnecting; | - |
1045 | | - |
1046 | if (backend) { | 0 |
1047 | delete backend; | - |
1048 | backend = 0; | - |
1049 | } | 0 |
1050 | | - |
1051 | cookedHeaders.clear(); | - |
1052 | rawHeaders.clear(); | - |
1053 | | - |
1054 | preMigrationDownloaded = bytesDownloaded; | - |
1055 | | - |
1056 | backend = manager->d_func()->findBackend(operation, request); | - |
1057 | | - |
1058 | if (backend) { | 0 |
1059 | backend->setParent(q); | - |
1060 | backend->reply = this; | - |
1061 | backend->setResumeOffset(bytesDownloaded); | - |
1062 | } | 0 |
1063 | | - |
1064 | | - |
1065 | QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection); | - |
1066 | | - |
1067 | | - |
1068 | | - |
1069 | | - |
1070 | return true; never executed: return true; | 0 |
1071 | } | - |
1072 | | - |
1073 | | - |
1074 | QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent, | - |
1075 | const QNetworkRequest &req, | - |
1076 | QNetworkAccessManager::Operation op) | - |
1077 | : QNetworkReply(parent) | - |
1078 | { | - |
1079 | setRequest(req); | - |
1080 | setUrl(req.url()); | - |
1081 | setOperation(op); | - |
1082 | | - |
1083 | qRegisterMetaType<QNetworkReply::NetworkError>(); | - |
1084 | | - |
1085 | QString msg = QCoreApplication::translate("QNetworkAccessManager", | - |
1086 | "Network access is disabled."); | - |
1087 | setError(UnknownNetworkError, msg); | - |
1088 | | - |
1089 | QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, | - |
1090 | QArgument<QNetworkReply::NetworkError >("QNetworkReply::NetworkError", UnknownNetworkError)); | - |
1091 | QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); | - |
1092 | } | 0 |
1093 | | - |
1094 | QDisabledNetworkReply::~QDisabledNetworkReply() | - |
1095 | { | - |
1096 | } | - |
1097 | | - |
1098 | | - |
1099 | | - |
1100 | | - |
1101 | | - |
| | |