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