| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qhttpprotocolhandler.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | QHttpProtocolHandler::QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel) | - | ||||||||||||||||||
| 7 | : QAbstractProtocolHandler(channel) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | } executed 731 times by 8 tests: end of blockExecuted by:
| 731 | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | void QHttpProtocolHandler::_q_receiveReply() | - | ||||||||||||||||||
| 12 | { | - | ||||||||||||||||||
| 13 | ((!(m_socket)) ? qt_assert("m_socket",__FILE__,56) : qt_noop()); | - | ||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | if (!m_reply
| 7-9894 | ||||||||||||||||||
| 16 | if (m_socket->bytesAvailable() > 0
| 0-7 | ||||||||||||||||||
| 17 | QMessageLogger(__FILE__, 60, __PRETTY_FUNCTION__).warning() << "QAbstractProtocolHandler::_q_receiveReply() called without QHttpNetworkReply," never executed: QMessageLogger(__FILE__, 60, __PRETTY_FUNCTION__).warning() << "QAbstractProtocolHandler::_q_receiveReply() called without QHttpNetworkReply," << m_socket->bytesAvailable() << "bytes on socket."; | 0 | ||||||||||||||||||
| 18 | << m_socket->bytesAvailable() << "bytes on socket."; never executed: QMessageLogger(__FILE__, 60, __PRETTY_FUNCTION__).warning() << "QAbstractProtocolHandler::_q_receiveReply() called without QHttpNetworkReply," << m_socket->bytesAvailable() << "bytes on socket."; | 0 | ||||||||||||||||||
| 19 | m_channel->close(); | - | ||||||||||||||||||
| 20 | return; executed 7 times by 1 test: return;Executed by:
| 7 | ||||||||||||||||||
| 21 | } | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | if (!qobject_cast<QHttpNetworkConnection*>(m_connection)
| 0-9894 | ||||||||||||||||||
| 27 | return; never executed: return; | 0 | ||||||||||||||||||
| 28 | } | - | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | QAbstractSocket::SocketState socketState = m_socket->state(); | - | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | if (socketState == QAbstractSocket::UnconnectedState
| 32-9862 | ||||||||||||||||||
| 34 | if (m_socket->bytesAvailable() <= 0
| 0-32 | ||||||||||||||||||
| 35 | if (m_reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState
| 16 | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; | - | ||||||||||||||||||
| 38 | m_channel->allDone(); | - | ||||||||||||||||||
| 39 | return; executed 16 times by 1 test: return;Executed by:
| 16 | ||||||||||||||||||
| 40 | } else { | - | ||||||||||||||||||
| 41 | m_channel->handleUnexpectedEOF(); | - | ||||||||||||||||||
| 42 | return; executed 16 times by 2 tests: return;Executed by:
| 16 | ||||||||||||||||||
| 43 | } | - | ||||||||||||||||||
| 44 | } else { | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | } never executed: end of block | 0 | ||||||||||||||||||
| 47 | } | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | qint64 bytes = 0; | - | ||||||||||||||||||
| 51 | qint64 lastBytes = bytes; | - | ||||||||||||||||||
| 52 | do { | - | ||||||||||||||||||
| 53 | lastBytes = bytes; | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | QHttpNetworkReplyPrivate::ReplyState state = m_reply->d_func()->state; | - | ||||||||||||||||||
| 56 | switch (state) { | - | ||||||||||||||||||
| 57 | case executed 1693 times by 7 tests: QHttpNetworkReplyPrivate::NothingDoneState:case QHttpNetworkReplyPrivate::NothingDoneState:Executed by:
executed 1693 times by 7 tests: {case QHttpNetworkReplyPrivate::NothingDoneState:Executed by:
| 1693 | ||||||||||||||||||
| 58 | m_reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState; | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | } | - | ||||||||||||||||||
| 61 | case executed 113 times by 2 tests: QHttpNetworkReplyPrivate::ReadingStatusState:case QHttpNetworkReplyPrivate::ReadingStatusState:Executed by:
executed 113 times by 2 tests: case QHttpNetworkReplyPrivate::ReadingStatusState:Executed by:
code before this statement executed 1693 times by 7 tests: {case QHttpNetworkReplyPrivate::ReadingStatusState:Executed by:
| 113-1693 | ||||||||||||||||||
| 62 | qint64 statusBytes = m_reply->d_func()->readStatus(m_socket); | - | ||||||||||||||||||
| 63 | if (statusBytes == -1
| 70-1736 | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | m_channel->handleUnexpectedEOF(); | - | ||||||||||||||||||
| 66 | return; executed 70 times by 1 test: return;Executed by:
| 70 | ||||||||||||||||||
| 67 | } | - | ||||||||||||||||||
| 68 | bytes += statusBytes; | - | ||||||||||||||||||
| 69 | m_channel->lastStatus = m_reply->d_func()->statusCode; | - | ||||||||||||||||||
| 70 | break; executed 1736 times by 7 tests: break;Executed by:
| 1736 | ||||||||||||||||||
| 71 | } | - | ||||||||||||||||||
| 72 | case executed 1701 times by 7 tests: QHttpNetworkReplyPrivate::ReadingHeaderState:case QHttpNetworkReplyPrivate::ReadingHeaderState:Executed by:
executed 1701 times by 7 tests: {case QHttpNetworkReplyPrivate::ReadingHeaderState:Executed by:
| 1701 | ||||||||||||||||||
| 73 | QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func(); | - | ||||||||||||||||||
| 74 | qint64 headerBytes = replyPrivate->readHeader(m_socket); | - | ||||||||||||||||||
| 75 | if (headerBytes == -1
| 6-1695 | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | m_channel->handleUnexpectedEOF(); | - | ||||||||||||||||||
| 78 | return; executed 6 times by 1 test: return;Executed by:
| 6 | ||||||||||||||||||
| 79 | } | - | ||||||||||||||||||
| 80 | bytes += headerBytes; | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState
| 71-1624 | ||||||||||||||||||
| 83 | if (replyPrivate->isCompressed()
| 1-1616 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | replyPrivate->removeAutoDecompressHeader(); | - | ||||||||||||||||||
| 86 | } executed 7 times by 1 test: else {end of blockExecuted by:
| 7 | ||||||||||||||||||
| 87 | replyPrivate->autoDecompress = false; | - | ||||||||||||||||||
| 88 | } executed 1617 times by 7 tests: end of blockExecuted by:
| 1617 | ||||||||||||||||||
| 89 | if (replyPrivate->statusCode == 100
| 7-1617 | ||||||||||||||||||
| 90 | replyPrivate->clearHttpLayerInformation(); | - | ||||||||||||||||||
| 91 | replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState; | - | ||||||||||||||||||
| 92 | break; executed 7 times by 1 test: break;Executed by:
| 7 | ||||||||||||||||||
| 93 | } | - | ||||||||||||||||||
| 94 | if (replyPrivate->shouldEmitSignals()
| 199-1418 | ||||||||||||||||||
| 95 | m_reply->headerChanged(); executed 1418 times by 7 tests: m_reply->headerChanged();Executed by:
| 1418 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | if (!replyPrivate->expectContent()
| 152-1465 | ||||||||||||||||||
| 101 | replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState; | - | ||||||||||||||||||
| 102 | m_channel->allDone(); | - | ||||||||||||||||||
| 103 | break; executed 152 times by 4 tests: break;Executed by:
| 152 | ||||||||||||||||||
| 104 | } | - | ||||||||||||||||||
| 105 | } executed 1465 times by 6 tests: end of blockExecuted by:
| 1465 | ||||||||||||||||||
| 106 | break; executed 1536 times by 6 tests: break;Executed by:
| 1536 | ||||||||||||||||||
| 107 | } | - | ||||||||||||||||||
| 108 | case executed 18056 times by 6 tests: QHttpNetworkReplyPrivate::ReadingDataState:case QHttpNetworkReplyPrivate::ReadingDataState:Executed by:
executed 18056 times by 6 tests: {case QHttpNetworkReplyPrivate::ReadingDataState:Executed by:
| 18056 | ||||||||||||||||||
| 109 | QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func(); | - | ||||||||||||||||||
| 110 | if (m_socket->state() == QAbstractSocket::ConnectedState
| 0-18056 | ||||||||||||||||||
| 111 | replyPrivate->downstreamLimited
| 0-17319 | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | return; executed 241 times by 2 tests: return;Executed by:
| 241 | ||||||||||||||||||
| 120 | } | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | if (replyPrivate->userProvidedDownloadBuffer
| 2657-15158 | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | qint64 haveRead = replyPrivate->readBodyVeryFast(m_socket, replyPrivate->userProvidedDownloadBuffer + replyPrivate->totalProgress); | - | ||||||||||||||||||
| 128 | if (haveRead > 0
| 1167-1490 | ||||||||||||||||||
| 129 | bytes += haveRead; | - | ||||||||||||||||||
| 130 | replyPrivate->totalProgress += haveRead; | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); | - | ||||||||||||||||||
| 133 | } executed 1490 times by 3 tests: else if (haveRead == 0end of blockExecuted by:
| 2-1490 | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | } executed 1165 times by 1 test: else if (haveRead < 0end of blockExecuted by:
| 0-1165 | ||||||||||||||||||
| 136 | m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::RemoteHostClosedError); | - | ||||||||||||||||||
| 137 | break; executed 2 times by 2 tests: break;Executed by:
| 2 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | } executed 2655 times by 3 tests: else if (!replyPrivate->isChunked()end of blockExecuted by:
| 10-14715 | ||||||||||||||||||
| 140 | && replyPrivate->bodyLength > 0
| 19-14686 | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | qint64 haveRead = replyPrivate->readBodyFast(m_socket, &replyPrivate->responseData); | - | ||||||||||||||||||
| 144 | bytes += haveRead; | - | ||||||||||||||||||
| 145 | replyPrivate->totalProgress += haveRead; | - | ||||||||||||||||||
| 146 | if (replyPrivate->shouldEmitSignals()
| 249-14437 | ||||||||||||||||||
| 147 | m_reply->readyRead(); | - | ||||||||||||||||||
| 148 | m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); | - | ||||||||||||||||||
| 149 | } executed 14437 times by 3 tests: end of blockExecuted by:
| 14437 | ||||||||||||||||||
| 150 | } executed 14686 times by 3 tests: end of blockExecuted by:
| 14686 | ||||||||||||||||||
| 151 | else | - | ||||||||||||||||||
| 152 | { | - | ||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | qint64 haveRead = replyPrivate->readBody(m_socket, &replyPrivate->responseData); | - | ||||||||||||||||||
| 156 | if (haveRead > 0
| 183-289 | ||||||||||||||||||
| 157 | bytes += haveRead; | - | ||||||||||||||||||
| 158 | replyPrivate->totalProgress += haveRead; | - | ||||||||||||||||||
| 159 | if (replyPrivate->shouldEmitSignals()
| 3-286 | ||||||||||||||||||
| 160 | m_reply->readyRead(); | - | ||||||||||||||||||
| 161 | m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); | - | ||||||||||||||||||
| 162 | } executed 286 times by 4 tests: end of blockExecuted by:
| 286 | ||||||||||||||||||
| 163 | } executed 289 times by 4 tests: else if (haveRead == -1end of blockExecuted by:
| 1-289 | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::ProtocolFailure); | - | ||||||||||||||||||
| 166 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | } executed 471 times by 4 tests: end of blockExecuted by:
| 471 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState
| 1437-16375 | ||||||||||||||||||
| 171 | break; executed 16375 times by 6 tests: break;Executed by:
| 16375 | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | } | - | ||||||||||||||||||
| 175 | case executed 157 times by 2 tests: QHttpNetworkReplyPrivate::AllDoneState:case QHttpNetworkReplyPrivate::AllDoneState:Executed by:
executed 157 times by 2 tests: case QHttpNetworkReplyPrivate::AllDoneState:Executed by:
code before this statement executed 1437 times by 6 tests: case QHttpNetworkReplyPrivate::AllDoneState:Executed by:
| 157-1437 | ||||||||||||||||||
| 176 | m_channel->allDone(); | - | ||||||||||||||||||
| 177 | break; executed 1594 times by 6 tests: break;Executed by:
| 1594 | ||||||||||||||||||
| 178 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 179 | break; never executed: break; | 0 | ||||||||||||||||||
| 180 | } | - | ||||||||||||||||||
| 181 | } while (bytes != lastBytes
| 1030-12888 | ||||||||||||||||||
| 182 | } executed 9545 times by 7 tests: end of blockExecuted by:
| 9545 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | void QHttpProtocolHandler::_q_readyRead() | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | if (m_socket->state() == QAbstractSocket::ConnectedState
| 0-9717 | ||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | char c; | - | ||||||||||||||||||
| 192 | qint64 ret = m_socket->peek(&c, 1); | - | ||||||||||||||||||
| 193 | if (ret < 0
| 45-143 | ||||||||||||||||||
| 194 | m_channel->_q_error(m_socket->error()); | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | if (m_reply
| 13-32 | ||||||||||||||||||
| 197 | _q_receiveReply(); executed 32 times by 2 tests: _q_receiveReply();Executed by:
| 32 | ||||||||||||||||||
| 198 | return; executed 45 times by 3 tests: return;Executed by:
| 45 | ||||||||||||||||||
| 199 | } | - | ||||||||||||||||||
| 200 | } executed 143 times by 1 test: end of blockExecuted by:
| 143 | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | if (m_channel->isSocketWaiting()
| 5-8514 | ||||||||||||||||||
| 203 | if (m_socket->bytesAvailable()
| 137-9530 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | m_channel->state = QHttpNetworkConnectionChannel::ReadingState; | - | ||||||||||||||||||
| 208 | } executed 9530 times by 6 tests: end of blockExecuted by:
| 9530 | ||||||||||||||||||
| 209 | if (m_reply
| 0-9667 | ||||||||||||||||||
| 210 | _q_receiveReply(); executed 9667 times by 6 tests: _q_receiveReply();Executed by:
| 9667 | ||||||||||||||||||
| 211 | } executed 9667 times by 6 tests: end of blockExecuted by:
| 9667 | ||||||||||||||||||
| 212 | } executed 9672 times by 6 tests: end of blockExecuted by:
| 9672 | ||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | bool QHttpProtocolHandler::sendRequest() | - | ||||||||||||||||||
| 215 | { | - | ||||||||||||||||||
| 216 | m_reply = m_channel->reply; | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | if (!m_reply
| 0-6085 | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | QMessageLogger(__FILE__, 263, __PRETTY_FUNCTION__).warning("QAbstractProtocolHandler::sendRequest() called without QHttpNetworkReply"); | - | ||||||||||||||||||
| 221 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 222 | } | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | switch (m_channel->state) { | - | ||||||||||||||||||
| 225 | case executed 1443 times by 8 tests: QHttpNetworkConnectionChannel::IdleState:case QHttpNetworkConnectionChannel::IdleState:Executed by:
executed 1443 times by 8 tests: {case QHttpNetworkConnectionChannel::IdleState:Executed by:
| 1443 | ||||||||||||||||||
| 226 | if (!m_channel->ensureConnection()
| 121-1322 | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | return executed 121 times by 2 tests: false;return false;Executed by:
executed 121 times by 2 tests: return false;Executed by:
| 121 | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | QString scheme = m_channel->request.url().scheme(); | - | ||||||||||||||||||
| 233 | if (scheme == QLatin1String("preconnect-http")
| 0-1322 | ||||||||||||||||||
| 234 | || scheme == QLatin1String("preconnect-https")
| 0-1322 | ||||||||||||||||||
| 235 | m_channel->state = QHttpNetworkConnectionChannel::IdleState; | - | ||||||||||||||||||
| 236 | m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState; | - | ||||||||||||||||||
| 237 | m_channel->allDone(); | - | ||||||||||||||||||
| 238 | m_connection->preConnectFinished(); | - | ||||||||||||||||||
| 239 | m_reply = 0; | - | ||||||||||||||||||
| 240 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 241 | } | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | m_channel->written = 0; | - | ||||||||||||||||||
| 244 | m_channel->bytesTotal = 0; | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func(); | - | ||||||||||||||||||
| 247 | replyPrivate->clear(); | - | ||||||||||||||||||
| 248 | replyPrivate->connection = m_connection; | - | ||||||||||||||||||
| 249 | replyPrivate->connectionChannel = m_channel; | - | ||||||||||||||||||
| 250 | replyPrivate->autoDecompress = m_channel->request.d->autoDecompress; | - | ||||||||||||||||||
| 251 | replyPrivate->pipeliningUsed = false; | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | if (!m_channel->request.url().userInfo().isEmpty()
| 0-1296 | ||||||||||||||||||
| 256 | QUrl url = m_channel->request.url(); | - | ||||||||||||||||||
| 257 | QAuthenticator &auth = m_channel->authenticator; | - | ||||||||||||||||||
| 258 | if (url.userName() != auth.user()
| 10-16 | ||||||||||||||||||
| 259 | || (!url.password().isEmpty()
| 0-10 | ||||||||||||||||||
| 260 | auth.setUser(url.userName()); | - | ||||||||||||||||||
| 261 | auth.setPassword(url.password()); | - | ||||||||||||||||||
| 262 | m_connection->d_func()->copyCredentials(m_connection->d_func()->indexOf(m_socket), &auth, false); | - | ||||||||||||||||||
| 263 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | url.setUserInfo(QString()); | - | ||||||||||||||||||
| 267 | m_channel->request.setUrl(url); | - | ||||||||||||||||||
| 268 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | - | |||||||||||||||||||
| 271 | if (m_channel->request.withCredentials()
| 1-1321 | ||||||||||||||||||
| 272 | m_connection->d_func()->createAuthorization(m_socket, m_channel->request); executed 1321 times by 8 tests: m_connection->d_func()->createAuthorization(m_socket, m_channel->request);Executed by:
| 1321 | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | QByteArray header = QHttpNetworkRequestPrivate::header(m_channel->request, | - | ||||||||||||||||||
| 275 | (m_connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy)); | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | m_socket->write(header); | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice(); | - | ||||||||||||||||||
| 283 | if (uploadByteDevice
| 227-1095 | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | QObject::connect(uploadByteDevice, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "328"), m_channel, qFlagLocation("1""_q_uploadDataReadyRead()" "\0" __FILE__ ":" "328")); | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | m_channel->bytesTotal = m_channel->request.contentLength(); | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | m_channel->state = QHttpNetworkConnectionChannel::WritingState; | - | ||||||||||||||||||
| 290 | sendRequest(); | - | ||||||||||||||||||
| 291 | } executed 227 times by 3 tests: else {end of blockExecuted by:
| 227 | ||||||||||||||||||
| 292 | m_channel->state = QHttpNetworkConnectionChannel::WaitingState; | - | ||||||||||||||||||
| 293 | sendRequest(); | - | ||||||||||||||||||
| 294 | } executed 1095 times by 7 tests: end of blockExecuted by:
| 1095 | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | break; executed 1322 times by 8 tests: break;Executed by:
| 1322 | ||||||||||||||||||
| 297 | } | - | ||||||||||||||||||
| 298 | case executed 3320 times by 3 tests: QHttpNetworkConnectionChannel::WritingState:case QHttpNetworkConnectionChannel::WritingState:Executed by:
executed 3320 times by 3 tests: case QHttpNetworkConnectionChannel::WritingState:Executed by:
| 3320 | ||||||||||||||||||
| 299 | { | - | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice(); | - | ||||||||||||||||||
| 302 | if (!uploadByteDevice
| 0-3320 | ||||||||||||||||||
| 303 | if (uploadByteDevice
| 0-31 | ||||||||||||||||||
| 304 | m_reply->dataSendProgress(m_channel->written, m_channel->bytesTotal); executed 31 times by 1 test: m_reply->dataSendProgress(m_channel->written, m_channel->bytesTotal);Executed by:
| 31 | ||||||||||||||||||
| 305 | m_channel->state = QHttpNetworkConnectionChannel::WaitingState; | - | ||||||||||||||||||
| 306 | sendRequest(); | - | ||||||||||||||||||
| 307 | break; executed 31 times by 1 test: break;Executed by:
| 31 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | const qint64 socketBufferFill = 32*1024; | - | ||||||||||||||||||
| 312 | const qint64 socketWriteMaxSize = 16*1024; | - | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | QSslSocket *sslSocket = qobject_cast<QSslSocket*>(m_socket); | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | while ((
| 341-5428 | ||||||||||||||||||
| 319 | <= socketBufferFill
| 0-5428 | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | { | - | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | qint64 currentReadSize = 0; | - | ||||||||||||||||||
| 327 | qint64 desiredReadSize = qMin(socketWriteMaxSize, m_channel->bytesTotal - m_channel->written); | - | ||||||||||||||||||
| 328 | const char *readPointer = uploadByteDevice->readPointer(desiredReadSize, currentReadSize); | - | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | if (currentReadSize == -1
| 0-5428 | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::UnknownNetworkError); | - | ||||||||||||||||||
| 333 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 334 | } else if (readPointer == 0
| 0-2752 | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | break; executed 2752 times by 2 tests: break;Executed by:
| 2752 | ||||||||||||||||||
| 337 | } else { | - | ||||||||||||||||||
| 338 | if (m_channel->written != uploadByteDevice->pos()
| 0-2676 | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | QMessageLogger(__FILE__, 383, __PRETTY_FUNCTION__).warning() << "QHttpProtocolHandler: Internal error in sendRequest. Expected to write at position" << m_channel->written << "but read device is at" << uploadByteDevice->pos(); | - | ||||||||||||||||||
| 341 | ((!(m_channel->written == uploadByteDevice->pos())) ? qt_assert("m_channel->written == uploadByteDevice->pos()",__FILE__,384) : qt_noop()); | - | ||||||||||||||||||
| 342 | m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::ProtocolFailure); | - | ||||||||||||||||||
| 343 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 344 | } | - | ||||||||||||||||||
| 345 | qint64 currentWriteSize = m_socket->write(readPointer, currentReadSize); | - | ||||||||||||||||||
| 346 | if (currentWriteSize == -1
| 0-2676 | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::UnknownNetworkError); | - | ||||||||||||||||||
| 349 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 350 | } else { | - | ||||||||||||||||||
| 351 | m_channel->written += currentWriteSize; | - | ||||||||||||||||||
| 352 | uploadByteDevice->advanceReadPointer(currentWriteSize); | - | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | m_reply->dataSendProgress(m_channel->written, m_channel->bytesTotal); | - | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | if (m_channel->written == m_channel->bytesTotal
| 196-2480 | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | m_channel->state = QHttpNetworkConnectionChannel::WaitingState; | - | ||||||||||||||||||
| 359 | sendRequest(); | - | ||||||||||||||||||
| 360 | break; executed 196 times by 3 tests: break;Executed by:
| 196 | ||||||||||||||||||
| 361 | } | - | ||||||||||||||||||
| 362 | } executed 2480 times by 1 test: end of blockExecuted by:
| 2480 | ||||||||||||||||||
| 363 | } | - | ||||||||||||||||||
| 364 | } | - | ||||||||||||||||||
| 365 | break; executed 3289 times by 3 tests: break;Executed by:
| 3289 | ||||||||||||||||||
| 366 | } | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | case executed 1322 times by 8 tests: QHttpNetworkConnectionChannel::WaitingState:case QHttpNetworkConnectionChannel::WaitingState:Executed by:
executed 1322 times by 8 tests: case QHttpNetworkConnectionChannel::WaitingState:Executed by:
| 1322 | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice(); | - | ||||||||||||||||||
| 371 | if (uploadByteDevice
| 227-1095 | ||||||||||||||||||
| 372 | QObject::disconnect(uploadByteDevice, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "415"), m_channel, qFlagLocation("1""_q_uploadDataReadyRead()" "\0" __FILE__ ":" "415")); | - | ||||||||||||||||||
| 373 | } executed 227 times by 3 tests: end of blockExecuted by:
| 227 | ||||||||||||||||||
| 374 | if (m_socket->bytesAvailable()
| 197-1125 | ||||||||||||||||||
| 375 | QMetaObject::invokeMethod(m_channel, "_q_receiveReply", Qt::QueuedConnection); executed 197 times by 2 tests: QMetaObject::invokeMethod(m_channel, "_q_receiveReply", Qt::QueuedConnection);Executed by:
| 197 | ||||||||||||||||||
| 376 | break; executed 1322 times by 8 tests: break;Executed by:
| 1322 | ||||||||||||||||||
| 377 | } | - | ||||||||||||||||||
| 378 | case never executed: QHttpNetworkConnectionChannel::ReadingState:case QHttpNetworkConnectionChannel::ReadingState:never executed: case QHttpNetworkConnectionChannel::ReadingState: | 0 | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 382 | break; never executed: break; | 0 | ||||||||||||||||||
| 383 | } | - | ||||||||||||||||||
| 384 | return executed 5964 times by 8 tests: true;return true;Executed by:
executed 5964 times by 8 tests: return true;Executed by:
| 5964 | ||||||||||||||||||
| 385 | } | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |