qhttpprotocolhandler.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qhttpprotocolhandler.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2014 BlackBerry Limited. All rights reserved.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtNetwork module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include <private/qhttpprotocolhandler_p.h>-
42#include <private/qnoncontiguousbytedevice_p.h>-
43#include <private/qhttpnetworkconnectionchannel_p.h>-
44-
45#ifndef QT_NO_HTTP-
46-
47QT_BEGIN_NAMESPACE-
48-
49QHttpProtocolHandler::QHttpProtocolHandler(QHttpNetworkConnectionChannel *channel)-
50 : QAbstractProtocolHandler(channel)-
51{-
52}
executed 731 times by 8 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
731
53-
54void QHttpProtocolHandler::_q_receiveReply()-
55{-
56 Q_ASSERT(m_socket);-
57-
58 if (!m_reply) {
!m_replyDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 9894 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
7-9894
59 if (m_socket->bytesAvailable() > 0)
m_socket->bytesAvailable() > 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-7
60 qWarning() << "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
61 << 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
62 m_channel->close();-
63 return;
executed 7 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
7
64 }-
65-
66 // only run when the QHttpNetworkConnection is not currently being destructed, e.g.-
67 // this function is called from _q_disconnected which is called because-
68 // of ~QHttpNetworkConnectionPrivate-
69 if (!qobject_cast<QHttpNetworkConnection*>(m_connection)) {
!qobject_cast<...(m_connection)Description
TRUEnever evaluated
FALSEevaluated 9894 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
0-9894
70 return;
never executed: return;
0
71 }-
72-
73 QAbstractSocket::SocketState socketState = m_socket->state();-
74-
75 // connection might be closed to signal the end of data-
76 if (socketState == QAbstractSocket::UnconnectedState) {
socketState ==...connectedStateDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 9862 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
32-9862
77 if (m_socket->bytesAvailable() <= 0) {
m_socket->byte...ailable() <= 0Description
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-32
78 if (m_reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) {
m_reply->d_fun...adingDataStateDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
16
79 // finish this reply. this case happens when the server did not send a content length-
80 m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;-
81 m_channel->allDone();-
82 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
16
83 } else {-
84 m_channel->handleUnexpectedEOF();-
85 return;
executed 16 times by 2 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
16
86 }-
87 } else {-
88 // socket not connected but still bytes for reading.. just continue in this function-
89 }
never executed: end of block
0
90 }-
91-
92 // read loop for the response-
93 qint64 bytes = 0;-
94 qint64 lastBytes = bytes;-
95 do {-
96 lastBytes = bytes;-
97-
98 QHttpNetworkReplyPrivate::ReplyState state = m_reply->d_func()->state;-
99 switch (state) {-
100 case QHttpNetworkReplyPrivate::NothingDoneState: {
executed 1693 times by 7 tests: case QHttpNetworkReplyPrivate::NothingDoneState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1693
101 m_reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState;-
102 // fallthrough-
103 }-
104 case QHttpNetworkReplyPrivate::ReadingStatusState: {
code before this statement executed 1693 times by 7 tests: case QHttpNetworkReplyPrivate::ReadingStatusState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
executed 113 times by 2 tests: case QHttpNetworkReplyPrivate::ReadingStatusState:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
113-1693
105 qint64 statusBytes = m_reply->d_func()->readStatus(m_socket);-
106 if (statusBytes == -1) {
statusBytes == -1Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1736 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
70-1736
107 // connection broke while reading status. also handled if later _q_disconnected is called-
108 m_channel->handleUnexpectedEOF();-
109 return;
executed 70 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
70
110 }-
111 bytes += statusBytes;-
112 m_channel->lastStatus = m_reply->d_func()->statusCode;-
113 break;
executed 1736 times by 7 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1736
114 }-
115 case QHttpNetworkReplyPrivate::ReadingHeaderState: {
executed 1701 times by 7 tests: case QHttpNetworkReplyPrivate::ReadingHeaderState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1701
116 QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func();-
117 qint64 headerBytes = replyPrivate->readHeader(m_socket);-
118 if (headerBytes == -1) {
headerBytes == -1Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1695 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
6-1695
119 // connection broke while reading headers. also handled if later _q_disconnected is called-
120 m_channel->handleUnexpectedEOF();-
121 return;
executed 6 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
6
122 }-
123 bytes += headerBytes;-
124 // If headers were parsed successfully now it is the ReadingDataState-
125 if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) {
replyPrivate->...adingDataStateDescription
TRUEevaluated 1624 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 71 times by 1 test
Evaluated by:
  • tst_QNetworkReply
71-1624
126 if (replyPrivate->isCompressed() && replyPrivate->autoDecompress) {
replyPrivate->isCompressed()Description
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 1616 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
replyPrivate->autoDecompressDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QHttpNetworkConnection
1-1616
127 // remove the Content-Length from header-
128 replyPrivate->removeAutoDecompressHeader();-
129 } else {
executed 7 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
7
130 replyPrivate->autoDecompress = false;-
131 }
executed 1617 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1617
132 if (replyPrivate->statusCode == 100) {
replyPrivate->...tusCode == 100Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1617 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
7-1617
133 replyPrivate->clearHttpLayerInformation();-
134 replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState;-
135 break; // ignore
executed 7 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
7
136 }-
137 if (replyPrivate->shouldEmitSignals())
replyPrivate->...dEmitSignals()Description
TRUEevaluated 1418 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 199 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
199-1418
138 emit m_reply->headerChanged();
executed 1418 times by 7 tests: m_reply->headerChanged();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1418
139 // After headerChanged had been emitted-
140 // we can suddenly have a replyPrivate->userProvidedDownloadBuffer-
141 // this is handled in the ReadingDataState however-
142-
143 if (!replyPrivate->expectContent()) {
!replyPrivate->expectContent()Description
TRUEevaluated 152 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEevaluated 1465 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
152-1465
144 replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState;-
145 m_channel->allDone();-
146 break;
executed 152 times by 4 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
152
147 }-
148 }
executed 1465 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1465
149 break;
executed 1536 times by 6 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1536
150 }-
151 case QHttpNetworkReplyPrivate::ReadingDataState: {
executed 18056 times by 6 tests: case QHttpNetworkReplyPrivate::ReadingDataState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
18056
152 QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func();-
153 if (m_socket->state() == QAbstractSocket::ConnectedState &&
m_socket->stat...ConnectedStateDescription
TRUEevaluated 18056 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-18056
154 replyPrivate->downstreamLimited && !replyPrivate->responseData.isEmpty() && replyPrivate->shouldEmitSignals()) {
replyPrivate->...nstreamLimitedDescription
TRUEevaluated 737 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 17319 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
!replyPrivate-...Data.isEmpty()Description
TRUEevaluated 241 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 496 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
replyPrivate->...dEmitSignals()Description
TRUEevaluated 241 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-17319
155 // (only do the following when still connected, not when we have already been disconnected and there is still data)-
156 // We already have some HTTP body data. We don't read more from the socket until-
157 // this is fetched by QHttpNetworkAccessHttpBackend. If we would read more,-
158 // we could not limit our read buffer usage.-
159 // We only do this when shouldEmitSignals==true because our HTTP parsing-
160 // always needs to parse the 401/407 replies. Therefore they don't really obey-
161 // to the read buffer maximum size, but we don't care since they should be small.-
162 return;
executed 241 times by 2 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
241
163 }-
164-
165 if (replyPrivate->userProvidedDownloadBuffer) {
replyPrivate->...DownloadBufferDescription
TRUEevaluated 2657 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 15158 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
2657-15158
166 // the user provided a direct buffer where we should put all our data in.-
167 // this only works when we can tell the user the content length and he/she can allocate-
168 // the buffer in that size.-
169 // note that this call will read only from the still buffered data-
170 qint64 haveRead = replyPrivate->readBodyVeryFast(m_socket, replyPrivate->userProvidedDownloadBuffer + replyPrivate->totalProgress);-
171 if (haveRead > 0) {
haveRead > 0Description
TRUEevaluated 1490 times by 3 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 1167 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
1167-1490
172 bytes += haveRead;-
173 replyPrivate->totalProgress += haveRead;-
174 // the user will get notified of it via progress signal-
175 emit m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);-
176 } else if (haveRead == 0) {
executed 1490 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
haveRead == 0Description
TRUEevaluated 1165 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
2-1490
177 // Happens since this called in a loop. Currently no bytes available.-
178 } else if (haveRead < 0) {
executed 1165 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
haveRead < 0Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
0-1165
179 m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::RemoteHostClosedError);-
180 break;
executed 2 times by 2 tests: break;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
2
181 }-
182 } else if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress
executed 2655 times by 3 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
!replyPrivate->isChunked()Description
TRUEevaluated 14715 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
FALSEevaluated 443 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
!replyPrivate->autoDecompressDescription
TRUEevaluated 14705 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkReply
10-14715
183 && replyPrivate->bodyLength > 0) {
replyPrivate->bodyLength > 0Description
TRUEevaluated 14686 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_QNetworkReply
19-14686
184 // bulk files like images should fulfill these properties and-
185 // we can therefore save on memory copying-
186 qint64 haveRead = replyPrivate->readBodyFast(m_socket, &replyPrivate->responseData);-
187 bytes += haveRead;-
188 replyPrivate->totalProgress += haveRead;-
189 if (replyPrivate->shouldEmitSignals()) {
replyPrivate->...dEmitSignals()Description
TRUEevaluated 14437 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
FALSEevaluated 249 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
249-14437
190 emit m_reply->readyRead();-
191 emit m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);-
192 }
executed 14437 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
14437
193 }
executed 14686 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
14686
194 else-
195 {-
196 // use the traditional slower reading (for compressed encoding, chunked encoding,-
197 // no content-length etc)-
198 qint64 haveRead = replyPrivate->readBody(m_socket, &replyPrivate->responseData);-
199 if (haveRead > 0) {
haveRead > 0Description
TRUEevaluated 289 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 183 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
183-289
200 bytes += haveRead;-
201 replyPrivate->totalProgress += haveRead;-
202 if (replyPrivate->shouldEmitSignals()) {
replyPrivate->...dEmitSignals()Description
TRUEevaluated 286 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-286
203 emit m_reply->readyRead();-
204 emit m_reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);-
205 }
executed 286 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
286
206 } else if (haveRead == -1) {
executed 289 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
haveRead == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 182 times by 4 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
1-289
207 // Some error occurred-
208 m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::ProtocolFailure);-
209 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkReply
1
210 }-
211 }
executed 471 times by 4 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
471
212 // still in ReadingDataState? This function will be called again by the socket's readyRead-
213 if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState)
replyPrivate->...adingDataStateDescription
TRUEevaluated 16375 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 1437 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1437-16375
214 break;
executed 16375 times by 6 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
16375
215-
216 // everything done, fall through-
217 }-
218 case QHttpNetworkReplyPrivate::AllDoneState:
code before this statement executed 1437 times by 6 tests: case QHttpNetworkReplyPrivate::AllDoneState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
executed 157 times by 2 tests: case QHttpNetworkReplyPrivate::AllDoneState:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
157-1437
219 m_channel->allDone();-
220 break;
executed 1594 times by 6 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1594
221 default:
never executed: default:
0
222 break;
never executed: break;
0
223 }-
224 } while (bytes != lastBytes && m_reply);
bytes != lastBytesDescription
TRUEevaluated 12888 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 8515 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
m_replyDescription
TRUEevaluated 11858 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 1030 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1030-12888
225}
executed 9545 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9545
226-
227void QHttpProtocolHandler::_q_readyRead()-
228{-
229 if (m_socket->state() == QAbstractSocket::ConnectedState && m_socket->bytesAvailable() == 0) {
m_socket->stat...ConnectedStateDescription
TRUEevaluated 9717 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
m_socket->byte...ailable() == 0Description
TRUEevaluated 188 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 9529 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
0-9717
230 // We got a readyRead but no bytes are available..-
231 // This happens for the Unbuffered QTcpSocket-
232 // Also check if socket is in ConnectedState since-
233 // this function may also be invoked via the event loop.-
234 char c;-
235 qint64 ret = m_socket->peek(&c, 1);-
236 if (ret < 0) {
ret < 0Description
TRUEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 143 times by 1 test
Evaluated by:
  • tst_QNetworkReply
45-143
237 m_channel->_q_error(m_socket->error());-
238 // We still need to handle the reply so it emits its signals etc.-
239 if (m_reply)
m_replyDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 13 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
13-32
240 _q_receiveReply();
executed 32 times by 2 tests: _q_receiveReply();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
32
241 return;
executed 45 times by 3 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
45
242 }-
243 }
executed 143 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
143
244-
245 if (m_channel->isSocketWaiting() || m_channel->isSocketReading()) {
m_channel->isSocketWaiting()Description
TRUEevaluated 1158 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 8514 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
m_channel->isSocketReading()Description
TRUEevaluated 8509 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
5-8514
246 if (m_socket->bytesAvailable()) {
m_socket->bytesAvailable()Description
TRUEevaluated 9530 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 137 times by 1 test
Evaluated by:
  • tst_QNetworkReply
137-9530
247 // We might get a spurious call from readMoreLater()-
248 // call of the QHttpNetworkConnection even while the socket is disconnecting.-
249 // Therefore check if there is actually bytes available before changing the channel state.-
250 m_channel->state = QHttpNetworkConnectionChannel::ReadingState;-
251 }
executed 9530 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9530
252 if (m_reply)
m_replyDescription
TRUEevaluated 9667 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-9667
253 _q_receiveReply();
executed 9667 times by 6 tests: _q_receiveReply();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9667
254 }
executed 9667 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9667
255}
executed 9672 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9672
256-
257bool QHttpProtocolHandler::sendRequest()-
258{-
259 m_reply = m_channel->reply;-
260-
261 if (!m_reply) {
!m_replyDescription
TRUEnever evaluated
FALSEevaluated 6085 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-6085
262 // heh, how should that happen!-
263 qWarning("QAbstractProtocolHandler::sendRequest() called without QHttpNetworkReply");-
264 return false;
never executed: return false;
0
265 }-
266-
267 switch (m_channel->state) {-
268 case QHttpNetworkConnectionChannel::IdleState: { // write the header
executed 1443 times by 8 tests: case QHttpNetworkConnectionChannel::IdleState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1443
269 if (!m_channel->ensureConnection()) {
!m_channel->ensureConnection()Description
TRUEevaluated 121 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 1322 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
121-1322
270 // wait for the connection (and encryption) to be done-
271 // sendRequest will be called again from either-
272 // _q_connected or _q_encrypted-
273 return false;
executed 121 times by 2 tests: return false;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
121
274 }-
275 QString scheme = m_channel->request.url().scheme();-
276 if (scheme == QLatin1String("preconnect-http")
scheme == QLat...connect-http")Description
TRUEnever evaluated
FALSEevaluated 1322 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-1322
277 || scheme == QLatin1String("preconnect-https")) {
scheme == QLat...onnect-https")Description
TRUEnever evaluated
FALSEevaluated 1322 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-1322
278 m_channel->state = QHttpNetworkConnectionChannel::IdleState;-
279 m_reply->d_func()->state = QHttpNetworkReplyPrivate::AllDoneState;-
280 m_channel->allDone();-
281 m_connection->preConnectFinished(); // will only decrease the counter-
282 m_reply = 0; // so we can reuse this channel-
283 return true; // we have a working connection and are done
never executed: return true;
0
284 }-
285-
286 m_channel->written = 0; // excluding the header-
287 m_channel->bytesTotal = 0;-
288-
289 QHttpNetworkReplyPrivate *replyPrivate = m_reply->d_func();-
290 replyPrivate->clear();-
291 replyPrivate->connection = m_connection;-
292 replyPrivate->connectionChannel = m_channel;-
293 replyPrivate->autoDecompress = m_channel->request.d->autoDecompress;-
294 replyPrivate->pipeliningUsed = false;-
295-
296 // if the url contains authentication parameters, use the new ones-
297 // both channels will use the new authentication parameters-
298 if (!m_channel->request.url().userInfo().isEmpty() && m_channel->request.withCredentials()) {
!m_channel->re...fo().isEmpty()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1296 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
m_channel->req...hCredentials()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1296
299 QUrl url = m_channel->request.url();-
300 QAuthenticator &auth = m_channel->authenticator;-
301 if (url.userName() != auth.user()
url.userName() != auth.user()Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkReply
10-16
302 || (!url.password().isEmpty() && url.password() != auth.password())) {
!url.password().isEmpty()Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
url.password()...uth.password()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-10
303 auth.setUser(url.userName());-
304 auth.setPassword(url.password());-
305 m_connection->d_func()->copyCredentials(m_connection->d_func()->indexOf(m_socket), &auth, false);-
306 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
18
307 // clear the userinfo, since we use the same request for resending-
308 // userinfo in url can conflict with the one in the authenticator-
309 url.setUserInfo(QString());-
310 m_channel->request.setUrl(url);-
311 }
executed 26 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
26
312 // Will only be false if Qt WebKit is performing a cross-origin XMLHttpRequest-
313 // and withCredentials has not been set to true.-
314 if (m_channel->request.withCredentials())
m_channel->req...hCredentials()Description
TRUEevaluated 1321 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-1321
315 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:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1321
316#ifndef QT_NO_NETWORKPROXY-
317 QByteArray header = QHttpNetworkRequestPrivate::header(m_channel->request,-
318 (m_connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy));-
319#else-
320 QByteArray header = QHttpNetworkRequestPrivate::header(m_channel->request, false);-
321#endif-
322 m_socket->write(header);-
323 // flushing is dangerous (QSslSocket calls transmit which might read or error)-
324// m_socket->flush();-
325 QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice();-
326 if (uploadByteDevice) {
uploadByteDeviceDescription
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 1095 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
227-1095
327 // connect the signals so this function gets called again-
328 QObject::connect(uploadByteDevice, SIGNAL(readyRead()), m_channel, SLOT(_q_uploadDataReadyRead()));-
329-
330 m_channel->bytesTotal = m_channel->request.contentLength();-
331-
332 m_channel->state = QHttpNetworkConnectionChannel::WritingState; // start writing data-
333 sendRequest(); //recurse-
334 } else {
executed 227 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
227
335 m_channel->state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response-
336 sendRequest(); //recurse-
337 }
executed 1095 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1095
338-
339 break;
executed 1322 times by 8 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1322
340 }-
341 case QHttpNetworkConnectionChannel::WritingState:
executed 3320 times by 3 tests: case QHttpNetworkConnectionChannel::WritingState:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
3320
342 {-
343 // write the data-
344 QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice();-
345 if (!uploadByteDevice || m_channel->bytesTotal == m_channel->written) {
!uploadByteDeviceDescription
TRUEnever evaluated
FALSEevaluated 3320 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
m_channel->byt...annel->writtenDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 3289 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
0-3320
346 if (uploadByteDevice)
uploadByteDeviceDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-31
347 emit 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:
  • tst_QNetworkReply
31
348 m_channel->state = QHttpNetworkConnectionChannel::WaitingState; // now wait for response-
349 sendRequest(); // recurse-
350 break;
executed 31 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
31
351 }-
352-
353 // only feed the QTcpSocket buffer when there is less than 32 kB in it-
354 const qint64 socketBufferFill = 32*1024;-
355 const qint64 socketWriteMaxSize = 16*1024;-
356-
357-
358#ifndef QT_NO_SSL-
359 QSslSocket *sslSocket = qobject_cast<QSslSocket*>(m_socket);-
360 // if it is really an ssl socket, check more than just bytesToWrite()-
361 while ((m_socket->bytesToWrite() + (sslSocket ? sslSocket->encryptedBytesToWrite() : 0))
sslSocketDescription
TRUEevaluated 2854 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2915 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
(m_socket->byt...cketBufferFillDescription
TRUEevaluated 5428 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 341 times by 1 test
Evaluated by:
  • tst_QNetworkReply
341-5428
362 <= socketBufferFill && m_channel->bytesTotal != m_channel->written)
(m_socket->byt...cketBufferFillDescription
TRUEevaluated 5428 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 341 times by 1 test
Evaluated by:
  • tst_QNetworkReply
m_channel->byt...annel->writtenDescription
TRUEevaluated 5428 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEnever evaluated
0-5428
363#else-
364 while (m_socket->bytesToWrite() <= socketBufferFill-
365 && m_channel->bytesTotal != m_channel->written)-
366#endif-
367 {-
368 // get pointer to upload data-
369 qint64 currentReadSize = 0;-
370 qint64 desiredReadSize = qMin(socketWriteMaxSize, m_channel->bytesTotal - m_channel->written);-
371 const char *readPointer = uploadByteDevice->readPointer(desiredReadSize, currentReadSize);-
372-
373 if (currentReadSize == -1) {
currentReadSize == -1Description
TRUEnever evaluated
FALSEevaluated 5428 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
0-5428
374 // premature eof happened-
375 m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::UnknownNetworkError);-
376 return false;
never executed: return false;
0
377 } else if (readPointer == 0 || currentReadSize == 0) {
readPointer == 0Description
TRUEevaluated 2752 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 2676 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
currentReadSize == 0Description
TRUEnever evaluated
FALSEevaluated 2676 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
0-2752
378 // nothing to read currently, break the loop-
379 break;
executed 2752 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
2752
380 } else {-
381 if (m_channel->written != uploadByteDevice->pos()) {
m_channel->wri...eDevice->pos()Description
TRUEnever evaluated
FALSEevaluated 2676 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
0-2676
382 // Sanity check. This was useful in tracking down an upload corruption.-
383 qWarning() << "QHttpProtocolHandler: Internal error in sendRequest. Expected to write at position" << m_channel->written << "but read device is at" << uploadByteDevice->pos();-
384 Q_ASSERT(m_channel->written == uploadByteDevice->pos());-
385 m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::ProtocolFailure);-
386 return false;
never executed: return false;
0
387 }-
388 qint64 currentWriteSize = m_socket->write(readPointer, currentReadSize);-
389 if (currentWriteSize == -1 || currentWriteSize != currentReadSize) {
currentWriteSize == -1Description
TRUEnever evaluated
FALSEevaluated 2676 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
currentWriteSi...urrentReadSizeDescription
TRUEnever evaluated
FALSEevaluated 2676 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
0-2676
390 // socket broke down-
391 m_connection->d_func()->emitReplyError(m_socket, m_reply, QNetworkReply::UnknownNetworkError);-
392 return false;
never executed: return false;
0
393 } else {-
394 m_channel->written += currentWriteSize;-
395 uploadByteDevice->advanceReadPointer(currentWriteSize);-
396-
397 emit m_reply->dataSendProgress(m_channel->written, m_channel->bytesTotal);-
398-
399 if (m_channel->written == m_channel->bytesTotal) {
m_channel->wri...el->bytesTotalDescription
TRUEevaluated 196 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 2480 times by 1 test
Evaluated by:
  • tst_QNetworkReply
196-2480
400 // make sure this function is called once again-
401 m_channel->state = QHttpNetworkConnectionChannel::WaitingState;-
402 sendRequest();-
403 break;
executed 196 times by 3 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
196
404 }-
405 }
executed 2480 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
2480
406 }-
407 }-
408 break;
executed 3289 times by 3 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
3289
409 }-
410-
411 case QHttpNetworkConnectionChannel::WaitingState:
executed 1322 times by 8 tests: case QHttpNetworkConnectionChannel::WaitingState:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1322
412 {-
413 QNonContiguousByteDevice* uploadByteDevice = m_channel->request.uploadByteDevice();-
414 if (uploadByteDevice) {
uploadByteDeviceDescription
TRUEevaluated 227 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEevaluated 1095 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
227-1095
415 QObject::disconnect(uploadByteDevice, SIGNAL(readyRead()), m_channel, SLOT(_q_uploadDataReadyRead()));-
416 }
executed 227 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
227
417-
418 // HTTP pipelining-
419 //m_connection->d_func()->fillPipeline(m_socket);-
420 //m_socket->flush();-
421-
422 // ensure we try to receive a reply in all cases, even if _q_readyRead_ hat not been called-
423 // this is needed if the sends an reply before we have finished sending the request. In that-
424 // case receiveReply had been called before but ignored the server reply-
425 if (m_socket->bytesAvailable())
m_socket->bytesAvailable()Description
TRUEevaluated 197 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 1125 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
197-1125
426 QMetaObject::invokeMethod(m_channel, "_q_receiveReply", Qt::QueuedConnection);
executed 197 times by 2 tests: QMetaObject::invokeMethod(m_channel, "_q_receiveReply", Qt::QueuedConnection);
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
197
427 break;
executed 1322 times by 8 tests: break;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
1322
428 }-
429 case QHttpNetworkConnectionChannel::ReadingState:
never executed: case QHttpNetworkConnectionChannel::ReadingState:
0
430 // ignore _q_bytesWritten in these states-
431 // fall through-
432 default:
never executed: default:
0
433 break;
never executed: break;
0
434 }-
435 return true;
executed 5964 times by 8 tests: return true;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
5964
436}-
437-
438QT_END_NAMESPACE-
439-
440#endif // QT_NO_HTTP-
Source codeSwitch to Preprocessed file

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