OpenCoverage

qhttpnetworkconnectionchannel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qhttpnetworkconnectionchannel.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 "qhttpnetworkconnectionchannel_p.h"-
42#include "qhttpnetworkconnection_p.h"-
43#include "private/qnoncontiguousbytedevice_p.h"-
44-
45#include <qpair.h>-
46#include <qdebug.h>-
47-
48#ifndef QT_NO_HTTP-
49-
50#include <private/qhttpprotocolhandler_p.h>-
51#include <private/qspdyprotocolhandler_p.h>-
52-
53#ifndef QT_NO_SSL-
54# include <QtNetwork/qsslkey.h>-
55# include <QtNetwork/qsslcipher.h>-
56# include <QtNetwork/qsslconfiguration.h>-
57#endif-
58-
59#ifndef QT_NO_BEARERMANAGEMENT-
60#include "private/qnetworksession_p.h"-
61#endif-
62-
63QT_BEGIN_NAMESPACE-
64-
65// TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp-
66-
67// Because in-flight when sending a request, the server might close our connection (because the persistent HTTP-
68// connection times out)-
69// We use 3 because we can get a _q_error 3 times depending on the timing:-
70static const int reconnectAttemptsDefault = 3;-
71-
72QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel()-
73 : socket(0)-
74 , ssl(false)-
75 , isInitialized(false)-
76 , state(IdleState)-
77 , reply(0)-
78 , written(0)-
79 , bytesTotal(0)-
80 , resendCurrent(false)-
81 , lastStatus(0)-
82 , pendingEncrypt(false)-
83 , reconnectAttempts(reconnectAttemptsDefault)-
84 , authMethod(QAuthenticatorPrivate::None)-
85 , proxyAuthMethod(QAuthenticatorPrivate::None)-
86 , authenticationCredentialsSent(false)-
87 , proxyCredentialsSent(false)-
88 , protocolHandler(0)-
89#ifndef QT_NO_SSL-
90 , ignoreAllSslErrors(false)-
91#endif-
92 , pipeliningSupported(PipeliningSupportUnknown)-
93 , networkLayerPreference(QAbstractSocket::AnyIPProtocol)-
94 , connection(0)-
95{-
96 // Inlining this function in the header leads to compiler error on-
97 // release-armv5, on at least timebox 9.2 and 10.1.-
98}
executed 3416 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
3416
99-
100void QHttpNetworkConnectionChannel::init()-
101{-
102#ifndef QT_NO_SSL-
103 if (connection->d_func()->encrypt)
connection->d_func()->encryptDescription
TRUEevaluated 108 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 646 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
108-646
104 socket = new QSslSocket;
executed 108 times by 3 tests: socket = new QSslSocket;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
108
105 else-
106 socket = new QTcpSocket;
executed 646 times by 8 tests: socket = new QTcpSocket;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
646
107#else-
108 socket = new QTcpSocket;-
109#endif-
110#ifndef QT_NO_BEARERMANAGEMENT-
111 //push session down to socket-
112 if (networkSession)
networkSessionDescription
TRUEevaluated 710 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 44 times by 1 test
Evaluated by:
  • tst_QHttpNetworkConnection
44-710
113 socket->setProperty("_q_networksession", QVariant::fromValue(networkSession));
executed 710 times by 8 tests: socket->setProperty("_q_networksession", QVariant::fromValue(networkSession));
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
710
114#endif-
115#ifndef QT_NO_NETWORKPROXY-
116 // Set by QNAM anyway, but let's be safe here-
117 socket->setProxy(QNetworkProxy::NoProxy);-
118#endif-
119-
120 // After some back and forth in all the last years, this is now a DirectConnection because otherwise-
121 // the state inside the *Socket classes gets messed up, also in conjunction with the socket notifiers-
122 // which behave slightly differently on Windows vs Linux-
123 QObject::connect(socket, SIGNAL(bytesWritten(qint64)),-
124 this, SLOT(_q_bytesWritten(qint64)),-
125 Qt::DirectConnection);-
126 QObject::connect(socket, SIGNAL(connected()),-
127 this, SLOT(_q_connected()),-
128 Qt::DirectConnection);-
129 QObject::connect(socket, SIGNAL(readyRead()),-
130 this, SLOT(_q_readyRead()),-
131 Qt::DirectConnection);-
132-
133 // The disconnected() and error() signals may already come-
134 // while calling connectToHost().-
135 // In case of a cached hostname or an IP this-
136 // will then emit a signal to the user of QNetworkReply-
137 // but cannot be caught because the user did not have a chance yet-
138 // to connect to QNetworkReply's signals.-
139 qRegisterMetaType<QAbstractSocket::SocketError>();-
140 QObject::connect(socket, SIGNAL(disconnected()),-
141 this, SLOT(_q_disconnected()),-
142 Qt::DirectConnection);-
143 QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),-
144 this, SLOT(_q_error(QAbstractSocket::SocketError)),-
145 Qt::DirectConnection);-
146-
147-
148#ifndef QT_NO_NETWORKPROXY-
149 QObject::connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),-
150 this, SLOT(_q_proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),-
151 Qt::DirectConnection);-
152#endif-
153-
154#ifndef QT_NO_SSL-
155 QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket);-
156 if (sslSocket) {
sslSocketDescription
TRUEevaluated 108 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 646 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
108-646
157 // won't be a sslSocket if encrypt is false-
158 QObject::connect(sslSocket, SIGNAL(encrypted()),-
159 this, SLOT(_q_encrypted()),-
160 Qt::DirectConnection);-
161 QObject::connect(sslSocket, SIGNAL(sslErrors(QList<QSslError>)),-
162 this, SLOT(_q_sslErrors(QList<QSslError>)),-
163 Qt::DirectConnection);-
164 QObject::connect(sslSocket, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)),-
165 this, SLOT(_q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)),-
166 Qt::DirectConnection);-
167 QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)),-
168 this, SLOT(_q_encryptedBytesWritten(qint64)),-
169 Qt::DirectConnection);-
170-
171 if (ignoreAllSslErrors)
ignoreAllSslErrorsDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 97 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
11-97
172 sslSocket->ignoreSslErrors();
executed 11 times by 2 tests: sslSocket->ignoreSslErrors();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
11
173-
174 if (!ignoreSslErrorsList.isEmpty())
!ignoreSslErrorsList.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 108 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-108
175 sslSocket->ignoreSslErrors(ignoreSslErrorsList);
never executed: sslSocket->ignoreSslErrors(ignoreSslErrorsList);
0
176-
177 if (!sslConfiguration.isNull())
!sslConfiguration.isNull()Description
TRUEevaluated 59 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 49 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
49-59
178 sslSocket->setSslConfiguration(sslConfiguration);
executed 59 times by 2 tests: sslSocket->setSslConfiguration(sslConfiguration);
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
59
179 } else {
executed 108 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
108
180#endif // QT_NO_SSL-
181 protocolHandler.reset(new QHttpProtocolHandler(this));-
182#ifndef QT_NO_SSL-
183 }
executed 646 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
646
184#endif-
185-
186#ifndef QT_NO_NETWORKPROXY-
187 if (proxy.type() != QNetworkProxy::NoProxy)
proxy.type() !...Proxy::NoProxyDescription
TRUEevaluated 101 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 653 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
101-653
188 socket->setProxy(proxy);
executed 101 times by 3 tests: socket->setProxy(proxy);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
101
189#endif-
190 isInitialized = true;-
191}
executed 754 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
754
192-
193-
194void QHttpNetworkConnectionChannel::close()-
195{-
196 if (!socket)
!socketDescription
TRUEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 406 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
4-406
197 state = QHttpNetworkConnectionChannel::IdleState;
executed 4 times by 3 tests: state = QHttpNetworkConnectionChannel::IdleState;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
4
198 else if (socket->state() == QAbstractSocket::UnconnectedState)
socket->state(...connectedStateDescription
TRUEevaluated 182 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 224 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
182-224
199 state = QHttpNetworkConnectionChannel::IdleState;
executed 182 times by 4 tests: state = QHttpNetworkConnectionChannel::IdleState;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
182
200 else-
201 state = QHttpNetworkConnectionChannel::ClosingState;
executed 224 times by 4 tests: state = QHttpNetworkConnectionChannel::ClosingState;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
224
202-
203 // pendingEncrypt must only be true in between connected and encrypted states-
204 pendingEncrypt = false;-
205-
206 if (socket) {
socketDescription
TRUEevaluated 406 times by 5 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
4-406
207 // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while-
208 // there is no socket yet.-
209 socket->close();-
210 }
executed 405 times by 5 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
405
211}
executed 409 times by 5 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
409
212-
213-
214void QHttpNetworkConnectionChannel::abort()-
215{-
216 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-13
217 state = QHttpNetworkConnectionChannel::IdleState;
never executed: state = QHttpNetworkConnectionChannel::IdleState;
0
218 else if (socket->state() == QAbstractSocket::UnconnectedState)
socket->state(...connectedStateDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-13
219 state = QHttpNetworkConnectionChannel::IdleState;
never executed: state = QHttpNetworkConnectionChannel::IdleState;
0
220 else-
221 state = QHttpNetworkConnectionChannel::ClosingState;
executed 13 times by 1 test: state = QHttpNetworkConnectionChannel::ClosingState;
Executed by:
  • tst_QNetworkReply
13
222-
223 // pendingEncrypt must only be true in between connected and encrypted states-
224 pendingEncrypt = false;-
225-
226 if (socket) {
socketDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-13
227 // socket can be 0 since the host lookup is done from qhttpnetworkconnection.cpp while-
228 // there is no socket yet.-
229 socket->abort();-
230 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
13
231}
executed 13 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
13
232-
233-
234bool QHttpNetworkConnectionChannel::sendRequest()-
235{-
236 Q_ASSERT(!protocolHandler.isNull());-
237 return protocolHandler->sendRequest();
executed 4643 times by 8 tests: return protocolHandler->sendRequest();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
4643
238}-
239-
240-
241void QHttpNetworkConnectionChannel::_q_receiveReply()-
242{-
243 Q_ASSERT(!protocolHandler.isNull());-
244 protocolHandler->_q_receiveReply();-
245}
executed 202 times by 2 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
202
246-
247void QHttpNetworkConnectionChannel::_q_readyRead()-
248{-
249 Q_ASSERT(!protocolHandler.isNull());-
250 protocolHandler->_q_readyRead();-
251}
executed 11090 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
11090
252-
253// called when unexpectedly reading a -1 or when data is expected but socket is closed-
254void QHttpNetworkConnectionChannel::handleUnexpectedEOF()-
255{-
256 Q_ASSERT(reply);-
257 if (reconnectAttempts <= 0) {
reconnectAttempts <= 0Description
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 65 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
27-65
258 // too many errors reading/receiving/parsing the status, close the socket and emit error-
259 requeueCurrentlyPipelinedRequests();-
260 close();-
261 reply->d_func()->errorString = connection->d_func()->errorDetail(QNetworkReply::RemoteHostClosedError, socket);-
262 emit reply->finishedWithError(QNetworkReply::RemoteHostClosedError, reply->d_func()->errorString);-
263 reply = 0;-
264 if (protocolHandler)
protocolHandlerDescription
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-27
265 protocolHandler->setReply(0);
executed 27 times by 2 tests: protocolHandler->setReply(0);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
27
266 request = QHttpNetworkRequest();-
267 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
268 } else {
executed 27 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
27
269 reconnectAttempts--;-
270 reply->d_func()->clear();-
271 reply->d_func()->connection = connection;-
272 reply->d_func()->connectionChannel = this;-
273 closeAndResendCurrentRequest();-
274 }
executed 65 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
65
275}-
276-
277bool QHttpNetworkConnectionChannel::ensureConnection()-
278{-
279 if (!isInitialized)
!isInitializedDescription
TRUEevaluated 754 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 1600 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
754-1600
280 init();
executed 754 times by 8 tests: init();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
754
281-
282 QAbstractSocket::SocketState socketState = socket->state();-
283-
284 // resend this request after we receive the disconnected signal-
285 // If !socket->isOpen() then we have already called close() on the socket, but there was still a-
286 // pending connectToHost() for which we hadn't seen a connected() signal, yet. The connected()-
287 // has now arrived (as indicated by socketState != ClosingState), but we cannot send anything on-
288 // such a socket anymore.-
289 if (socketState == QAbstractSocket::ClosingState ||
socketState ==...::ClosingStateDescription
TRUEnever evaluated
FALSEevaluated 2354 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-2354
290 (socketState != QAbstractSocket::UnconnectedState && !socket->isOpen())) {
socketState !=...connectedStateDescription
TRUEevaluated 1432 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 922 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
!socket->isOpen()Description
TRUEnever evaluated
FALSEevaluated 1432 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-1432
291 if (reply)
replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
292 resendCurrent = true;
never executed: resendCurrent = true;
0
293 return false;
never executed: return false;
0
294 }-
295-
296 // already trying to connect?-
297 if (socketState == QAbstractSocket::HostLookupState ||
socketState ==...ostLookupStateDescription
TRUEnever evaluated
FALSEevaluated 2354 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-2354
298 socketState == QAbstractSocket::ConnectingState) {
socketState ==...onnectingStateDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 2351 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
3-2351
299 return false;
executed 3 times by 1 test: return false;
Executed by:
  • tst_Spdy
3
300 }-
301-
302 // make sure that this socket is in a connected state, if not initiate-
303 // connection to the host.-
304 if (socketState != QAbstractSocket::ConnectedState) {
socketState !=...ConnectedStateDescription
TRUEevaluated 922 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 1429 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
922-1429
305 // connect to the host if not already connected.-
306 state = QHttpNetworkConnectionChannel::ConnectingState;-
307 pendingEncrypt = ssl;-
308-
309 // reset state-
310 pipeliningSupported = PipeliningSupportUnknown;-
311 authenticationCredentialsSent = false;-
312 proxyCredentialsSent = false;-
313 authenticator.detach();-
314 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(authenticator);-
315 priv->hasFailed = false;-
316 proxyAuthenticator.detach();-
317 priv = QAuthenticatorPrivate::getPrivate(proxyAuthenticator);-
318 priv->hasFailed = false;-
319-
320 // This workaround is needed since we use QAuthenticator for NTLM authentication. The "phase == Done"-
321 // is the usual criteria for emitting authentication signals. The "phase" is set to "Done" when the-
322 // last header for Authorization is generated by the QAuthenticator. Basic & Digest logic does not-
323 // check the "phase" for generating the Authorization header. NTLM authentication is a two stage-
324 // process & needs the "phase". To make sure the QAuthenticator uses the current username/password-
325 // the phase is reset to Start.-
326 priv = QAuthenticatorPrivate::getPrivate(authenticator);-
327 if (priv && priv->phase == QAuthenticatorPrivate::Done)
privDescription
TRUEevaluated 922 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
priv->phase ==...rPrivate::DoneDescription
TRUEnever evaluated
FALSEevaluated 922 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-922
328 priv->phase = QAuthenticatorPrivate::Start;
never executed: priv->phase = QAuthenticatorPrivate::Start;
0
329 priv = QAuthenticatorPrivate::getPrivate(proxyAuthenticator);-
330 if (priv && priv->phase == QAuthenticatorPrivate::Done)
privDescription
TRUEevaluated 922 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
priv->phase ==...rPrivate::DoneDescription
TRUEnever evaluated
FALSEevaluated 922 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-922
331 priv->phase = QAuthenticatorPrivate::Start;
never executed: priv->phase = QAuthenticatorPrivate::Start;
0
332-
333 QString connectHost = connection->d_func()->hostName;-
334 quint16 connectPort = connection->d_func()->port;-
335-
336#ifndef QT_NO_NETWORKPROXY-
337 // HTTPS always use transparent proxy.-
338 if (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy && !ssl) {
connection->d_...Proxy::NoProxyDescription
TRUEevaluated 95 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 827 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
!sslDescription
TRUEevaluated 95 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-827
339 connectHost = connection->d_func()->networkProxy.hostName();-
340 connectPort = connection->d_func()->networkProxy.port();-
341 }
executed 95 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
95
342 if (socket->proxy().type() == QNetworkProxy::HttpProxy) {
socket->proxy(...oxy::HttpProxyDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 899 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
23-899
343 // Make user-agent field available to HTTP proxy socket engine (QTBUG-17223)-
344 QByteArray value;-
345 // ensureConnection is called before any request has been assigned, but can also be called again if reconnecting-
346 if (request.url().isEmpty())
request.url().isEmpty()Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-21
347 value = connection->d_func()->predictNextRequest().headerField("user-agent");
executed 21 times by 2 tests: value = connection->d_func()->predictNextRequest().headerField("user-agent");
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
21
348 else-
349 value = request.headerField("user-agent");
executed 2 times by 1 test: value = request.headerField("user-agent");
Executed by:
  • tst_QNetworkReply
2
350 if (!value.isEmpty()) {
!value.isEmpty()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
6-17
351 QNetworkProxy proxy(socket->proxy());-
352 proxy.setRawHeader("User-Agent", value); //detaches-
353 socket->setProxy(proxy);-
354 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
6
355 }
executed 23 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
23
356#endif-
357 if (ssl) {
sslDescription
TRUEevaluated 127 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 795 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
127-795
358#ifndef QT_NO_SSL-
359 QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket);-
360-
361 // check whether we can re-use an existing SSL session-
362 // (meaning another socket in this connection has already-
363 // performed a full handshake)-
364 if (!connection->sslContext().isNull())
!connection->s...ext().isNull()Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 101 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
26-101
365 QSslSocketPrivate::checkSettingSslContext(sslSocket, connection->sslContext());
executed 26 times by 1 test: QSslSocketPrivate::checkSettingSslContext(sslSocket, connection->sslContext());
Executed by:
  • tst_QNetworkReply
26
366-
367 sslSocket->connectToHostEncrypted(connectHost, connectPort, QIODevice::ReadWrite, networkLayerPreference);-
368 if (ignoreAllSslErrors)
ignoreAllSslErrorsDescription
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 106 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
21-106
369 sslSocket->ignoreSslErrors();
executed 21 times by 2 tests: sslSocket->ignoreSslErrors();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
21
370 sslSocket->ignoreSslErrors(ignoreSslErrorsList);-
371-
372 // limit the socket read buffer size. we will read everything into-
373 // the QHttpNetworkReply anyway, so let's grow only that and not-
374 // here and there.-
375 socket->setReadBufferSize(64*1024);-
376#else-
377 // Need to dequeue the request so that we can emit the error.-
378 if (!reply)-
379 connection->d_func()->dequeueRequest(socket);-
380 connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError);-
381#endif-
382 } else {
executed 127 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
127
383 // In case of no proxy we can use the Unbuffered QTcpSocket-
384#ifndef QT_NO_NETWORKPROXY-
385 if (connection->d_func()->networkProxy.type() == QNetworkProxy::NoProxy
connection->d_...Proxy::NoProxyDescription
TRUEevaluated 700 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 95 times by 1 test
Evaluated by:
  • tst_QNetworkReply
95-700
386 && connection->cacheProxy().type() == QNetworkProxy::NoProxy
connection->ca...Proxy::NoProxyDescription
TRUEevaluated 700 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEnever evaluated
0-700
387 && connection->transparentProxy().type() == QNetworkProxy::NoProxy) {
connection->tr...Proxy::NoProxyDescription
TRUEevaluated 614 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 86 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
86-614
388#endif-
389 socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered, networkLayerPreference);-
390 // For an Unbuffered QTcpSocket, the read buffer size has a special meaning.-
391 socket->setReadBufferSize(1*1024);-
392#ifndef QT_NO_NETWORKPROXY-
393 } else {
executed 614 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
614
394 socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite, networkLayerPreference);-
395-
396 // limit the socket read buffer size. we will read everything into-
397 // the QHttpNetworkReply anyway, so let's grow only that and not-
398 // here and there.-
399 socket->setReadBufferSize(64*1024);-
400 }
executed 181 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
181
401#endif-
402 }-
403 return false;
executed 922 times by 8 tests: return false;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
922
404 }-
405-
406 // This code path for ConnectedState-
407 if (pendingEncrypt) {
pendingEncryptDescription
TRUEnever evaluated
FALSEevaluated 1429 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-1429
408 // Let's only be really connected when we have received the encrypted() signal. Else the state machine seems to mess up-
409 // and corrupt the things sent to the server.-
410 return false;
never executed: return false;
0
411 }-
412-
413 return true;
executed 1429 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
1429
414}-
415-
416void QHttpNetworkConnectionChannel::allDone()-
417{-
418 Q_ASSERT(reply);-
419-
420 if (!reply) {
!replyDescription
TRUEnever evaluated
FALSEevaluated 1762 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
0-1762
421 qWarning("QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt.io/");-
422 return;
never executed: return;
0
423 }-
424-
425 // while handling 401 & 407, we might reset the status code, so save this.-
426 bool emitFinished = reply->d_func()->shouldEmitSignals();-
427 bool connectionCloseEnabled = reply->d_func()->isConnectionCloseEnabled();-
428 detectPipeliningSupport();-
429-
430 handleStatus();-
431 // handleStatus() might have removed the reply because it already called connection->emitReplyError()-
432-
433 // queue the finished signal, this is required since we might send new requests from-
434 // slot connected to it. The socket will not fire readyRead signal, if we are already-
435 // in the slot connected to readyRead-
436 if (reply && emitFinished)
replyDescription
TRUEevaluated 1760 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
emitFinishedDescription
TRUEevaluated 1405 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
2-1760
437 QMetaObject::invokeMethod(reply, "finished", Qt::QueuedConnection);
executed 1405 times by 7 tests: QMetaObject::invokeMethod(reply, "finished", Qt::QueuedConnection);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1405
438-
439-
440 // reset the reconnection attempts after we receive a complete reply.-
441 // in case of failures, each channel will attempt two reconnects before emitting error.-
442 reconnectAttempts = reconnectAttemptsDefault;-
443-
444 // now the channel can be seen as free/idle again, all signal emissions for the reply have been done-
445 if (state != QHttpNetworkConnectionChannel::ClosingState)
state != QHttp...::ClosingStateDescription
TRUEevaluated 1762 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1762
446 state = QHttpNetworkConnectionChannel::IdleState;
executed 1762 times by 7 tests: state = QHttpNetworkConnectionChannel::IdleState;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1762
447-
448 // if it does not need to be sent again we can set it to 0-
449 // the previous code did not do that and we had problems with accidental re-sending of a-
450 // finished request.-
451 // Note that this may trigger a segfault at some other point. But then we can fix the underlying-
452 // problem.-
453 if (!resendCurrent) {
!resendCurrentDescription
TRUEevaluated 1437 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 325 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
325-1437
454 request = QHttpNetworkRequest();-
455 reply = 0;-
456 protocolHandler->setReply(0);-
457 }
executed 1437 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
1437
458-
459 // move next from pipeline to current request-
460 if (!alreadyPipelinedRequests.isEmpty()) {
!alreadyPipeli...ests.isEmpty()Description
TRUEevaluated 402 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 1360 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
402-1360
461 if (resendCurrent || connectionCloseEnabled || socket->state() != QAbstractSocket::ConnectedState) {
resendCurrentDescription
TRUEnever evaluated
FALSEevaluated 402 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
connectionCloseEnabledDescription
TRUEnever evaluated
FALSEevaluated 402 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
socket->state(...ConnectedStateDescription
TRUEnever evaluated
FALSEevaluated 402 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
0-402
462 // move the pipelined ones back to the main queue-
463 requeueCurrentlyPipelinedRequests();-
464 close();-
465 } else {
never executed: end of block
0
466 // there were requests pipelined in and we can continue-
467 HttpMessagePair messagePair = alreadyPipelinedRequests.takeFirst();-
468-
469 request = messagePair.first;-
470 reply = messagePair.second;-
471 protocolHandler->setReply(messagePair.second);-
472 state = QHttpNetworkConnectionChannel::ReadingState;-
473 resendCurrent = false;-
474-
475 written = 0; // message body, excluding the header, irrelevant here-
476 bytesTotal = 0; // message body total, excluding the header, irrelevant here-
477-
478 // pipeline even more-
479 connection->d_func()->fillPipeline(socket);-
480-
481 // continue reading-
482 //_q_receiveReply();-
483 // this was wrong, allDone gets called from that function anyway.-
484 }
executed 402 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
402
485 } else if (alreadyPipelinedRequests.isEmpty() && socket->bytesAvailable() > 0) {
alreadyPipelin...ests.isEmpty()Description
TRUEevaluated 1360 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
socket->bytesAvailable() > 0Description
TRUEnever evaluated
FALSEevaluated 1360 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
0-1360
486 // this is weird. we had nothing pipelined but still bytes available. better close it.-
487 close();-
488-
489 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
490 } else if (alreadyPipelinedRequests.isEmpty()) {
never executed: end of block
alreadyPipelin...ests.isEmpty()Description
TRUEevaluated 1360 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1360
491 if (connectionCloseEnabled)
connectionCloseEnabledDescription
TRUEevaluated 185 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 1175 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
185-1175
492 if (socket->state() != QAbstractSocket::UnconnectedState)
socket->state(...connectedStateDescription
TRUEevaluated 125 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 60 times by 1 test
Evaluated by:
  • tst_QNetworkReply
60-125
493 close();
executed 125 times by 2 tests: close();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
125
494 if (qobject_cast<QHttpNetworkConnection*>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 1360 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1360
495 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 1360 times by 7 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
1360
496 }
executed 1360 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
1360
497}
executed 1762 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
1762
498-
499void QHttpNetworkConnectionChannel::detectPipeliningSupport()-
500{-
501 Q_ASSERT(reply);-
502 // detect HTTP Pipelining support-
503 QByteArray serverHeaderField;-
504 if (-
505 // check for HTTP/1.1-
506 (reply->d_func()->majorVersion == 1 && reply->d_func()->minorVersion == 1)
reply->d_func(...orVersion == 1Description
TRUEevaluated 1762 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
reply->d_func(...orVersion == 1Description
TRUEevaluated 1521 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 241 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-1762
507 // check for not having connection close-
508 && (!reply->d_func()->isConnectionCloseEnabled())
(!reply->d_fun...loseEnabled())Description
TRUEevaluated 1517 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
4-1517
509 // check if it is still connected-
510 && (socket->state() == QAbstractSocket::ConnectedState)
(socket->state...onnectedState)Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkReply
10-1507
511 // check for broken servers in server reply header-
512 // this is adapted from http://mxr.mozilla.org/firefox/ident?i=SupportsPipelining-
513 && (serverHeaderField = reply->headerField("Server"), !serverHeaderField.contains("Microsoft-IIS/4."))
(serverHeaderF...soft-IIS/4."))Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1507
514 && (!serverHeaderField.contains("Microsoft-IIS/5."))
(!serverHeader...soft-IIS/5."))Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1507
515 && (!serverHeaderField.contains("Netscape-Enterprise/3."))
(!serverHeader...terprise/3."))Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1507
516 // this is adpoted from the knowledge of the Nokia 7.x browser team (DEF143319)-
517 && (!serverHeaderField.contains("WebLogic"))
(!serverHeader...s("WebLogic"))Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1507
518 && (!serverHeaderField.startsWith("Rocket")) // a Python Web Server, see Web2py.com
(!serverHeader...ith("Rocket"))Description
TRUEevaluated 1507 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1507
519 ) {-
520 pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningProbablySupported;-
521 } else {
executed 1507 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
1507
522 pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown;-
523 }
executed 255 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
255
524}-
525-
526// called when the connection broke and we need to queue some pipelined requests again-
527void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests()-
528{-
529 for (int i = 0; i < alreadyPipelinedRequests.length(); i++)
i < alreadyPip...uests.length()Description
TRUEnever evaluated
FALSEevaluated 136 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
0-136
530 connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i));
never executed: connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i));
0
531 alreadyPipelinedRequests.clear();-
532-
533 // only run when the QHttpNetworkConnection is not currently being destructed, e.g.-
534 // this function is called from _q_disconnected which is called because-
535 // of ~QHttpNetworkConnectionPrivate-
536 if (qobject_cast<QHttpNetworkConnection*>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 136 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEnever evaluated
0-136
537 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 136 times by 3 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
136
538}
executed 136 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
136
539-
540void QHttpNetworkConnectionChannel::handleStatus()-
541{-
542 Q_ASSERT(socket);-
543 Q_ASSERT(reply);-
544-
545 int statusCode = reply->statusCode();-
546 bool resend = false;-
547-
548 switch (statusCode) {-
549 case 301:
executed 3 times by 1 test: case 301:
Executed by:
  • tst_QNetworkProxyFactory
3
550 case 302:
never executed: case 302:
0
551 case 303:
never executed: case 303:
0
552 case 305:
never executed: case 305:
0
553 case 307: {
executed 6 times by 1 test: case 307:
Executed by:
  • tst_QNetworkReply
6
554 // Parse the response headers and get the "location" url-
555 QUrl redirectUrl = connection->d_func()->parseRedirectResponse(socket, reply);-
556 if (redirectUrl.isValid())
redirectUrl.isValid()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
4-5
557 reply->setRedirectUrl(redirectUrl);
executed 5 times by 1 test: reply->setRedirectUrl(redirectUrl);
Executed by:
  • tst_QNetworkReply
5
558-
559 if (qobject_cast<QHttpNetworkConnection *>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEnever evaluated
0-9
560 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 9 times by 2 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
9
561 break;
executed 9 times by 2 tests: break;
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
9
562 }-
563 case 401: // auth required
executed 302 times by 2 tests: case 401:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
302
564 case 407: // proxy auth required
executed 54 times by 1 test: case 407:
Executed by:
  • tst_QNetworkReply
54
565 if (connection->d_func()->handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) {
connection->d_... 407), resend)Description
TRUEevaluated 353 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-353
566 if (resend) {
resendDescription
TRUEevaluated 315 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
38-315
567 if (!resetUploadData())
!resetUploadData()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 314 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
1-314
568 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkReply
1
569-
570 reply->d_func()->eraseData();-
571-
572 if (alreadyPipelinedRequests.isEmpty()) {
alreadyPipelin...ests.isEmpty()Description
TRUEevaluated 314 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-314
573 // this does a re-send without closing the connection-
574 resendCurrent = true;-
575 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
576 } else {
executed 314 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
314
577 // we had requests pipelined.. better close the connection in closeAndResendCurrentRequest-
578 closeAndResendCurrentRequest();-
579 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
580 }
never executed: end of block
0
581 } else {-
582 //authentication cancelled, close the channel.-
583 close();-
584 }
executed 38 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
38
585 } else {-
586 emit reply->headerChanged();-
587 emit reply->readyRead();-
588 QNetworkReply::NetworkError errorCode = (statusCode == 407)
(statusCode == 407)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
1-2
589 ? QNetworkReply::ProxyAuthenticationRequiredError-
590 : QNetworkReply::AuthenticationRequiredError;-
591 reply->d_func()->errorString = connection->d_func()->errorDetail(errorCode, socket);-
592 emit reply->finishedWithError(errorCode, reply->d_func()->errorString);-
593 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
3
594 break;
executed 355 times by 2 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
355
595 default:
executed 1397 times by 6 tests: default:
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1397
596 if (qobject_cast<QHttpNetworkConnection*>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 1397 times by 6 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-1397
597 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 1397 times by 6 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1397
598 }
executed 1397 times by 6 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
1397
599}-
600-
601bool QHttpNetworkConnectionChannel::resetUploadData()-
602{-
603 if (!reply) {
!replyDescription
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 547 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
9-547
604 //this happens if server closes connection while QHttpNetworkConnectionPrivate::_q_startNextRequest is pending-
605 return false;
executed 9 times by 2 tests: return false;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
9
606 }-
607 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();-
608 if (!uploadByteDevice)
!uploadByteDeviceDescription
TRUEevaluated 420 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 127 times by 1 test
Evaluated by:
  • tst_QNetworkReply
127-420
609 return true;
executed 420 times by 2 tests: return true;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
420
610-
611 if (uploadByteDevice->reset()) {
uploadByteDevice->reset()Description
TRUEevaluated 126 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-126
612 written = 0;-
613 return true;
executed 126 times by 1 test: return true;
Executed by:
  • tst_QNetworkReply
126
614 } else {-
615 connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ContentReSendError);-
616 return false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QNetworkReply
1
617 }-
618}-
619-
620#ifndef QT_NO_NETWORKPROXY-
621-
622void QHttpNetworkConnectionChannel::setProxy(const QNetworkProxy &networkProxy)-
623{-
624 if (socket)
socketDescription
TRUEnever evaluated
FALSEevaluated 3251 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-3251
625 socket->setProxy(networkProxy);
never executed: socket->setProxy(networkProxy);
0
626-
627 proxy = networkProxy;-
628}
executed 3251 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
3251
629-
630#endif-
631-
632#ifndef QT_NO_SSL-
633-
634void QHttpNetworkConnectionChannel::ignoreSslErrors()-
635{-
636 if (socket)
socketDescription
TRUEevaluated 33 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 141 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
33-141
637 static_cast<QSslSocket *>(socket)->ignoreSslErrors();
executed 33 times by 3 tests: static_cast<QSslSocket *>(socket)->ignoreSslErrors();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
33
638-
639 ignoreAllSslErrors = true;-
640}
executed 174 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
174
641-
642-
643void QHttpNetworkConnectionChannel::ignoreSslErrors(const QList<QSslError> &errors)-
644{-
645 if (socket)
socketDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
6-30
646 static_cast<QSslSocket *>(socket)->ignoreSslErrors(errors);
executed 6 times by 1 test: static_cast<QSslSocket *>(socket)->ignoreSslErrors(errors);
Executed by:
  • tst_QNetworkReply
6
647-
648 ignoreSslErrorsList = errors;-
649}
executed 36 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
36
650-
651void QHttpNetworkConnectionChannel::setSslConfiguration(const QSslConfiguration &config)-
652{-
653 if (socket)
socketDescription
TRUEnever evaluated
FALSEevaluated 287 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_Spdy
0-287
654 static_cast<QSslSocket *>(socket)->setSslConfiguration(config);
never executed: static_cast<QSslSocket *>(socket)->setSslConfiguration(config);
0
655-
656 sslConfiguration = config;-
657}
executed 287 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
287
658-
659#endif-
660-
661void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)-
662{-
663 // this is only called for simple GET-
664-
665 QHttpNetworkRequest &request = pair.first;-
666 QHttpNetworkReply *reply = pair.second;-
667 reply->d_func()->clear();-
668 reply->d_func()->connection = connection;-
669 reply->d_func()->connectionChannel = this;-
670 reply->d_func()->autoDecompress = request.d->autoDecompress;-
671 reply->d_func()->pipeliningUsed = true;-
672-
673#ifndef QT_NO_NETWORKPROXY-
674 pipeline.append(QHttpNetworkRequestPrivate::header(request,-
675 (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy)));-
676#else-
677 pipeline.append(QHttpNetworkRequestPrivate::header(request, false));-
678#endif-
679-
680 alreadyPipelinedRequests.append(pair);-
681-
682 // pipelineFlush() needs to be called at some point afterwards-
683}
executed 402 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
402
684-
685void QHttpNetworkConnectionChannel::pipelineFlush()-
686{-
687 if (pipeline.isEmpty())
pipeline.isEmpty()Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QHttpNetworkConnection
FALSEevaluated 195 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
11-195
688 return;
executed 11 times by 1 test: return;
Executed by:
  • tst_QHttpNetworkConnection
11
689-
690 // The goal of this is so that we have everything in one TCP packet.-
691 // For the Unbuffered QTcpSocket this is manually needed, the buffered-
692 // QTcpSocket does it automatically.-
693 // Also, sometimes the OS does it for us (Nagle's algorithm) but that-
694 // happens only sometimes.-
695 socket->write(pipeline);-
696 pipeline.clear();-
697}
executed 195 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
195
698-
699-
700void QHttpNetworkConnectionChannel::closeAndResendCurrentRequest()-
701{-
702 requeueCurrentlyPipelinedRequests();-
703 close();-
704 if (reply)
replyDescription
TRUEevaluated 65 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-65
705 resendCurrent = true;
executed 65 times by 2 tests: resendCurrent = true;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
65
706 if (qobject_cast<QHttpNetworkConnection*>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 65 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-65
707 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 65 times by 2 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
65
708}
executed 65 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
65
709-
710void QHttpNetworkConnectionChannel::resendCurrentRequest()-
711{-
712 requeueCurrentlyPipelinedRequests();-
713 if (reply)
replyDescription
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
6-27
714 resendCurrent = true;
executed 27 times by 2 tests: resendCurrent = true;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
27
715 if (qobject_cast<QHttpNetworkConnection*>(connection))
qobject_cast<Q...*>(connection)Description
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
0-33
716 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 33 times by 2 tests: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
33
717}
executed 33 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
33
718-
719bool QHttpNetworkConnectionChannel::isSocketBusy() const-
720{-
721 return (state & QHttpNetworkConnectionChannel::BusyState);
executed 5417 times by 6 tests: return (state & QHttpNetworkConnectionChannel::BusyState);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
5417
722}-
723-
724bool QHttpNetworkConnectionChannel::isSocketWriting() const-
725{-
726 return (state & QHttpNetworkConnectionChannel::WritingState);
executed 3024 times by 3 tests: return (state & QHttpNetworkConnectionChannel::WritingState);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
3024
727}-
728-
729bool QHttpNetworkConnectionChannel::isSocketWaiting() const-
730{-
731 return (state & QHttpNetworkConnectionChannel::WaitingState);
executed 9678 times by 6 tests: return (state & QHttpNetworkConnectionChannel::WaitingState);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_Spdy
9678
732}-
733-
734bool QHttpNetworkConnectionChannel::isSocketReading() const-
735{-
736 return (state & QHttpNetworkConnectionChannel::ReadingState);
executed 8520 times by 5 tests: return (state & QHttpNetworkConnectionChannel::ReadingState);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkReply
  • tst_Spdy
8520
737}-
738-
739void QHttpNetworkConnectionChannel::_q_bytesWritten(qint64 bytes)-
740{-
741 Q_UNUSED(bytes);-
742 if (ssl) {
sslDescription
TRUEevaluated 1901 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 946 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
946-1901
743 // In the SSL case we want to send data from encryptedBytesWritten signal since that one-
744 // is the one going down to the actual network, not only into some SSL buffer.-
745 return;
executed 1901 times by 3 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
1901
746 }-
747-
748 // bytes have been written to the socket. write even more of them :)-
749 if (isSocketWriting())
isSocketWriting()Description
TRUEevaluated 233 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 713 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
233-713
750 sendRequest();
executed 233 times by 1 test: sendRequest();
Executed by:
  • tst_QNetworkReply
233
751 // otherwise we do nothing-
752}
executed 946 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
946
753-
754void QHttpNetworkConnectionChannel::_q_disconnected()-
755{-
756 if (state == QHttpNetworkConnectionChannel::ClosingState) {
state == QHttp...::ClosingStateDescription
TRUEevaluated 243 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
6-243
757 state = QHttpNetworkConnectionChannel::IdleState;-
758 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
759 return;
executed 243 times by 4 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
243
760 }-
761-
762 // read the available data before closing (also done in _q_error for other codepaths)-
763 if ((isSocketWaiting() || isSocketReading()) && socket->bytesAvailable()) {
isSocketWaiting()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
isSocketReading()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
socket->bytesAvailable()Description
TRUEnever evaluated
FALSEnever evaluated
0-6
764 if (reply) {
replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
765 state = QHttpNetworkConnectionChannel::ReadingState;-
766 _q_receiveReply();-
767 }
never executed: end of block
0
768 } else if (state == QHttpNetworkConnectionChannel::IdleState && resendCurrent) {
never executed: end of block
state == QHttp...nel::IdleStateDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
resendCurrentDescription
TRUEnever evaluated
FALSEnever evaluated
0-6
769 // re-sending request because the socket was in ClosingState-
770 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
771 }
never executed: end of block
0
772 state = QHttpNetworkConnectionChannel::IdleState;-
773-
774 requeueCurrentlyPipelinedRequests();-
775-
776 pendingEncrypt = false;-
777}
executed 6 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
6
778-
779-
780void QHttpNetworkConnectionChannel::_q_connected()-
781{-
782 // For the Happy Eyeballs we need to check if this is the first channel to connect.-
783 if (connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::HostLookupPending || connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4or6) {
connection->d_...tLookupPendingDescription
TRUEnever evaluated
FALSEevaluated 781 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
connection->d_...ivate::IPv4or6Description
TRUEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEevaluated 657 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-781
784 if (connection->d_func()->delayedConnectionTimer.isActive())
connection->d_...mer.isActive()Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEevaluated 120 times by 1 test
Evaluated by:
  • tst_QNetworkReply
4-120
785 connection->d_func()->delayedConnectionTimer.stop();
executed 4 times by 2 tests: connection->d_func()->delayedConnectionTimer.stop();
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
4
786 if (networkLayerPreference == QAbstractSocket::IPv4Protocol)
networkLayerPr...::IPv4ProtocolDescription
TRUEevaluated 124 times by 2 tests
Evaluated by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
FALSEnever evaluated
0-124
787 connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
executed 124 times by 2 tests: connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
124
788 else if (networkLayerPreference == QAbstractSocket::IPv6Protocol)
networkLayerPr...::IPv6ProtocolDescription
TRUEnever evaluated
FALSEnever evaluated
0
789 connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
never executed: connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
0
790 else {-
791 if (socket->peerAddress().protocol() == QAbstractSocket::IPv4Protocol)
socket->peerAd...::IPv4ProtocolDescription
TRUEnever evaluated
FALSEnever evaluated
0
792 connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
never executed: connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
0
793 else-
794 connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
never executed: connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
0
795 }-
796 connection->d_func()->networkLayerDetected(networkLayerPreference);-
797 } else {
executed 124 times by 2 tests: end of block
Executed by:
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
124
798 if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (networkLayerPreference != QAbstractSocket::IPv4Protocol))
(connection->d...Private::IPv4)Description
TRUEevaluated 656 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
(networkLayerP...:IPv4Protocol)Description
TRUEnever evaluated
FALSEevaluated 656 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-656
799 || ((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (networkLayerPreference != QAbstractSocket::IPv6Protocol))) {
(connection->d...Private::IPv6)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 656 times by 7 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
(networkLayerP...:IPv6Protocol)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
0-656
800 close();-
801 // This is the second connection so it has to be closed and we can schedule it for another request.-
802 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
803 return;
never executed: return;
0
804 }-
805 //The connections networkLayerState had already been decided.-
806 }
executed 657 times by 7 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
657
807-
808 // improve performance since we get the request sent by the kernel ASAP-
809 //socket->setSocketOption(QAbstractSocket::LowDelayOption, 1);-
810 // We have this commented out now. It did not have the effect we wanted. If we want to-
811 // do this properly, Qt has to combine multiple HTTP requests into one buffer-
812 // and send this to the kernel in one syscall and then the kernel immediately sends-
813 // it as one TCP packet because of TCP_NODELAY.-
814 // However, this code is currently not in Qt, so we rely on the kernel combining-
815 // the requests into one TCP packet.-
816-
817 // not sure yet if it helps, but it makes sense-
818 socket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);-
819-
820 pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown;-
821-
822 // ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again!-
823 //channels[i].reconnectAttempts = 2;-
824 if (ssl || pendingEncrypt) { // FIXME: Didn't work properly with pendingEncrypt only, we should refactor this into an EncrypingState
sslDescription
TRUEevaluated 121 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 660 times by 8 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
pendingEncryptDescription
TRUEnever evaluated
FALSEevaluated 660 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-660
825#ifndef QT_NO_SSL-
826 if (connection->sslContext().isNull()) {
connection->ss...ext().isNull()Description
TRUEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_QNetworkReply
26-95
827 // this socket is making the 1st handshake for this connection,-
828 // we need to set the SSL context so new sockets can reuse it-
829 QSharedPointer<QSslContext> socketSslContext = QSslSocketPrivate::sslContext(static_cast<QSslSocket*>(socket));-
830 if (!socketSslContext.isNull())
!socketSslContext.isNull()Description
TRUEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-95
831 connection->setSslContext(socketSslContext);
executed 95 times by 3 tests: connection->setSslContext(socketSslContext);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
95
832 }
executed 95 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
95
833#endif-
834 } else {
executed 121 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
121
835 state = QHttpNetworkConnectionChannel::IdleState;-
836 if (!reply)
!replyDescription
TRUEevaluated 524 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 136 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
136-524
837 connection->d_func()->dequeueRequest(socket);
executed 524 times by 8 tests: connection->d_func()->dequeueRequest(socket);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
524
838 if (reply)
replyDescription
TRUEevaluated 658 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 2 times by 1 test
Evaluated by:
  • tst_QHttpNetworkConnection
2-658
839 sendRequest();
executed 658 times by 8 tests: sendRequest();
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
658
840 }
executed 660 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
660
841}-
842-
843-
844void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socketError)-
845{-
846 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 199 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
0-199
847 return;
never executed: return;
0
848 QNetworkReply::NetworkError errorCode = QNetworkReply::UnknownNetworkError;-
849-
850 switch (socketError) {-
851 case QAbstractSocket::HostNotFoundError:
executed 2 times by 1 test: case QAbstractSocket::HostNotFoundError:
Executed by:
  • tst_QNetworkReply
2
852 errorCode = QNetworkReply::HostNotFoundError;-
853 break;
executed 2 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
2
854 case QAbstractSocket::ConnectionRefusedError:
executed 124 times by 2 tests: case QAbstractSocket::ConnectionRefusedError:
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
124
855 errorCode = QNetworkReply::ConnectionRefusedError;-
856 break;
executed 124 times by 2 tests: break;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
124
857 case QAbstractSocket::RemoteHostClosedError:
executed 53 times by 3 tests: case QAbstractSocket::RemoteHostClosedError:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
53
858 // This error for SSL comes twice in a row, first from SSL layer ("The TLS/SSL connection has been closed") then from TCP layer.-
859 // Depending on timing it can also come three times in a row (first time when we try to write into a closing QSslSocket).-
860 // The reconnectAttempts handling catches the cases where we can re-send the request.-
861 if (!reply && state == QHttpNetworkConnectionChannel::IdleState) {
!replyDescription
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
state == QHttp...nel::IdleStateDescription
TRUEevaluated 9 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QNetworkReply
8-36
862 // Not actually an error, it is normal for Keep-Alive connections to close after some time if no request-
863 // is sent on them. No need to error the other replies below. Just bail out here.-
864 // The _q_disconnected will handle the possibly pipelined replies-
865 return;
executed 9 times by 2 tests: return;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
9
866 } else if (state != QHttpNetworkConnectionChannel::IdleState && state != QHttpNetworkConnectionChannel::ReadingState) {
state != QHttp...nel::IdleStateDescription
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEnever evaluated
state != QHttp...::ReadingStateDescription
TRUEevaluated 39 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-44
867 // Try to reconnect/resend before sending an error.-
868 // While "Reading" the _q_disconnected() will handle this.-
869 if (reconnectAttempts-- > 0) {
reconnectAttempts-- > 0Description
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
FALSEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
6-33
870 resendCurrentRequest();-
871 return;
executed 33 times by 2 tests: return;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
33
872 } else {-
873 errorCode = QNetworkReply::RemoteHostClosedError;-
874 }
executed 6 times by 2 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
6
875 } else if (state == QHttpNetworkConnectionChannel::ReadingState) {
state == QHttp...::ReadingStateDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-5
876 if (!reply)
!replyDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-5
877 break;
never executed: break;
0
878-
879 if (!reply->d_func()->expectContent()) {
!reply->d_func...xpectContent()Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-5
880 // No content expected, this is a valid way to have the connection closed by the server-
881 // We need to invoke this asynchronously to make sure the state() of the socket is on QAbstractSocket::UnconnectedState-
882 QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection);-
883 return;
never executed: return;
0
884 }-
885 if (reply->contentLength() == -1 && !reply->d_func()->isChunked()) {
reply->contentLength() == -1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
!reply->d_func()->isChunked()Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-5
886 // There was no content-length header and it's not chunked encoding,-
887 // so this is a valid way to have the connection closed by the server-
888 // We need to invoke this asynchronously to make sure the state() of the socket is on QAbstractSocket::UnconnectedState-
889 QMetaObject::invokeMethod(this, "_q_receiveReply", Qt::QueuedConnection);-
890 return;
executed 5 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
5
891 }-
892 // ok, we got a disconnect even though we did not expect it-
893 // Try to read everything from the socket before we emit the error.-
894 if (socket->bytesAvailable()) {
socket->bytesAvailable()Description
TRUEnever evaluated
FALSEnever evaluated
0
895 // Read everything from the socket into the reply buffer.-
896 // we can ignore the readbuffersize as the data is already-
897 // in memory and we will not receive more data on the socket.-
898 reply->setReadBufferSize(0);-
899 reply->setDownstreamLimited(false);-
900 _q_receiveReply();-
901 if (!reply) {
!replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
902 // No more reply assigned after the previous call? Then it had been finished successfully.-
903 requeueCurrentlyPipelinedRequests();-
904 state = QHttpNetworkConnectionChannel::IdleState;-
905 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);-
906 return;
never executed: return;
0
907 }-
908 }
never executed: end of block
0
909-
910 errorCode = QNetworkReply::RemoteHostClosedError;-
911 } else {
never executed: end of block
0
912 errorCode = QNetworkReply::RemoteHostClosedError;-
913 }
never executed: end of block
0
914 break;
executed 6 times by 2 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
6
915 case QAbstractSocket::SocketTimeoutError:
never executed: case QAbstractSocket::SocketTimeoutError:
0
916 // try to reconnect/resend before sending an error.-
917 if (state == QHttpNetworkConnectionChannel::WritingState && (reconnectAttempts-- > 0)) {
state == QHttp...::WritingStateDescription
TRUEnever evaluated
FALSEnever evaluated
(reconnectAttempts-- > 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
918 resendCurrentRequest();-
919 return;
never executed: return;
0
920 }-
921 errorCode = QNetworkReply::TimeoutError;-
922 break;
never executed: break;
0
923 case QAbstractSocket::ProxyAuthenticationRequiredError:
executed 5 times by 2 tests: case QAbstractSocket::ProxyAuthenticationRequiredError:
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
5
924 errorCode = QNetworkReply::ProxyAuthenticationRequiredError;-
925 break;
executed 5 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
5
926 case QAbstractSocket::SslHandshakeFailedError:
executed 12 times by 3 tests: case QAbstractSocket::SslHandshakeFailedError:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
12
927 errorCode = QNetworkReply::SslHandshakeFailedError;-
928 break;
executed 12 times by 3 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
12
929 case QAbstractSocket::ProxyConnectionClosedError:
never executed: case QAbstractSocket::ProxyConnectionClosedError:
0
930 // try to reconnect/resend before sending an error.-
931 if (reconnectAttempts-- > 0) {
reconnectAttempts-- > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
932 resendCurrentRequest();-
933 return;
never executed: return;
0
934 }-
935 errorCode = QNetworkReply::ProxyConnectionClosedError;-
936 break;
never executed: break;
0
937 case QAbstractSocket::ProxyConnectionTimeoutError:
never executed: case QAbstractSocket::ProxyConnectionTimeoutError:
0
938 // try to reconnect/resend before sending an error.-
939 if (reconnectAttempts-- > 0) {
reconnectAttempts-- > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
940 resendCurrentRequest();-
941 return;
never executed: return;
0
942 }-
943 errorCode = QNetworkReply::ProxyTimeoutError;-
944 break;
never executed: break;
0
945 default:
executed 3 times by 2 tests: default:
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
3
946 // all other errors are treated as NetworkError-
947 errorCode = QNetworkReply::UnknownNetworkError;-
948 break;
executed 3 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_Spdy
3
949 }-
950 QPointer<QHttpNetworkConnection> that = connection;-
951 QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString());-
952-
953 // In the HostLookupPending state the channel should not emit the error.-
954 // This will instead be handled by the connection.-
955 if (!connection->d_func()->shouldEmitChannelError(socket))
!connection->d...lError(socket)Description
TRUEevaluated 122 times by 2 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 30 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
30-122
956 return;
executed 122 times by 2 tests: return;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
122
957-
958 // emit error for all waiting replies-
959 do {-
960 // Need to dequeu the request so that we can emit the error.-
961 if (!reply)
!replyDescription
TRUEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
12-20
962 connection->d_func()->dequeueRequest(socket);
executed 12 times by 3 tests: connection->d_func()->dequeueRequest(socket);
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
12
963-
964 if (reply) {
replyDescription
TRUEevaluated 29 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
3-29
965 reply->d_func()->errorString = errorString;-
966 emit reply->finishedWithError(errorCode, errorString);-
967 reply = 0;-
968 if (protocolHandler)
protocolHandlerDescription
TRUEevaluated 12 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
12-17
969 protocolHandler->setReply(0);
executed 12 times by 3 tests: protocolHandler->setReply(0);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
12
970 }
executed 29 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
29
971 } while (!connection->d_func()->highPriorityQueue.isEmpty()
executed 32 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
!connection->d...ueue.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 32 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
0-32
972 || !connection->d_func()->lowPriorityQueue.isEmpty());
!connection->d...ueue.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 30 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
2-30
973#ifndef QT_NO_SSL-
974 if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
connection->co...ectionTypeSPDYDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 27 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
3-27
975 QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();-
976 for (int a = 0; a < spdyPairs.count(); ++a) {
a < spdyPairs.count()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
3
977 // emit error for all replies-
978 QHttpNetworkReply *currentReply = spdyPairs.at(a).second;-
979 Q_ASSERT(currentReply);-
980 emit currentReply->finishedWithError(errorCode, errorString);-
981 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_Spdy
3
982 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_Spdy
3
983#endif // QT_NO_SSL-
984-
985 // send the next request-
986 QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection);-
987-
988 if (that) {
thatDescription
TRUEevaluated 30 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
0-30
989 //signal emission triggered event loop-
990 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 30 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
0-30
991 state = QHttpNetworkConnectionChannel::IdleState;
never executed: state = QHttpNetworkConnectionChannel::IdleState;
0
992 else if (socket->state() == QAbstractSocket::UnconnectedState)
socket->state(...connectedStateDescription
TRUEevaluated 17 times by 4 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
13-17
993 state = QHttpNetworkConnectionChannel::IdleState;
executed 17 times by 4 tests: state = QHttpNetworkConnectionChannel::IdleState;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
17
994 else-
995 state = QHttpNetworkConnectionChannel::ClosingState;
executed 13 times by 2 tests: state = QHttpNetworkConnectionChannel::ClosingState;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
13
996-
997 // pendingEncrypt must only be true in between connected and encrypted states-
998 pendingEncrypt = false;-
999 }
executed 30 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
30
1000}
executed 30 times by 4 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_Spdy
30
1001-
1002#ifndef QT_NO_NETWORKPROXY-
1003void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth)-
1004{-
1005#ifndef QT_NO_SSL-
1006 if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
connection->co...ectionTypeSPDYDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 39 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-39
1007 connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);-
1008 } else { // HTTP
executed 3 times by 1 test: end of block
Executed by:
  • tst_Spdy
3
1009#endif // QT_NO_SSL-
1010 // Need to dequeue the request before we can emit the error.-
1011 if (!reply)
!replyDescription
TRUEevaluated 37 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-37
1012 connection->d_func()->dequeueRequest(socket);
executed 37 times by 1 test: connection->d_func()->dequeueRequest(socket);
Executed by:
  • tst_QNetworkReply
37
1013 if (reply)
replyDescription
TRUEevaluated 39 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-39
1014 connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
executed 39 times by 1 test: connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
Executed by:
  • tst_QNetworkReply
39
1015#ifndef QT_NO_SSL-
1016 }
executed 39 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
39
1017#endif // QT_NO_SSL-
1018}-
1019#endif-
1020-
1021void QHttpNetworkConnectionChannel::_q_uploadDataReadyRead()-
1022{-
1023 if (reply)
replyDescription
TRUEevaluated 1964 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
FALSEnever evaluated
0-1964
1024 sendRequest();
executed 1964 times by 2 tests: sendRequest();
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
1964
1025}
executed 1964 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_QXmlInputSource
1964
1026-
1027#ifndef QT_NO_SSL-
1028void QHttpNetworkConnectionChannel::_q_encrypted()-
1029{-
1030 QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);-
1031 Q_ASSERT(sslSocket);-
1032-
1033 if (!protocolHandler) {
!protocolHandlerDescription
TRUEevaluated 91 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_QNetworkReply
10-91
1034 switch (sslSocket->sslConfiguration().nextProtocolNegotiationStatus()) {-
1035 case QSslConfiguration::NextProtocolNegotiationNegotiated: /* fall through */
executed 6 times by 1 test: case QSslConfiguration::NextProtocolNegotiationNegotiated:
Executed by:
  • tst_Spdy
6
1036 case QSslConfiguration::NextProtocolNegotiationUnsupported: {
never executed: case QSslConfiguration::NextProtocolNegotiationUnsupported:
0
1037 QByteArray nextProtocol = sslSocket->sslConfiguration().nextNegotiatedProtocol();-
1038 if (nextProtocol == QSslConfiguration::NextProtocolHttp1_1) {
nextProtocol =...rotocolHttp1_1Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_Spdy
0-6
1039 // fall through to create a QHttpProtocolHandler-
1040 } else if (nextProtocol == QSslConfiguration::NextProtocolSpdy3_0) {
never executed: end of block
nextProtocol =...rotocolSpdy3_0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEnever evaluated
0-6
1041 protocolHandler.reset(new QSpdyProtocolHandler(this));-
1042 connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeSPDY);-
1043 // no need to re-queue requests, if SPDY was enabled on the request it-
1044 // has gone to the SPDY queue already-
1045 break;
executed 6 times by 1 test: break;
Executed by:
  • tst_Spdy
6
1046 } else {-
1047 emitFinishedWithError(QNetworkReply::SslHandshakeFailedError,-
1048 "detected unknown Next Protocol Negotiation protocol");-
1049 break;
never executed: break;
0
1050 }-
1051 }-
1052 case QSslConfiguration::NextProtocolNegotiationNone:
code before this statement never executed: case QSslConfiguration::NextProtocolNegotiationNone:
executed 85 times by 3 tests: case QSslConfiguration::NextProtocolNegotiationNone:
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-85
1053 protocolHandler.reset(new QHttpProtocolHandler(this));-
1054 connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeHTTP);-
1055 // re-queue requests from SPDY queue to HTTP queue, if any-
1056 requeueSpdyRequests();-
1057 break;
executed 85 times by 3 tests: break;
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
85
1058 default:
never executed: default:
0
1059 emitFinishedWithError(QNetworkReply::SslHandshakeFailedError,-
1060 "detected unknown Next Protocol Negotiation protocol");-
1061 }
never executed: end of block
0
1062 }-
1063-
1064 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 101 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-101
1065 return; // ### error
never executed: return;
0
1066 state = QHttpNetworkConnectionChannel::IdleState;-
1067 pendingEncrypt = false;-
1068-
1069 if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
connection->co...ectionTypeSPDYDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 95 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
6-95
1070 // we call setSpdyWasUsed(true) on the replies in the SPDY handler when the request is sent-
1071 if (spdyRequestsToSend.count() > 0)
spdyRequestsToSend.count() > 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEnever evaluated
0-6
1072 // wait for data from the server first (e.g. initial window, max concurrent requests)-
1073 QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
executed 6 times by 1 test: QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
Executed by:
  • tst_Spdy
6
1074 } else { // HTTP
executed 6 times by 1 test: end of block
Executed by:
  • tst_Spdy
6
1075 if (!reply)
!replyDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 39 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
39-56
1076 connection->d_func()->dequeueRequest(socket);
executed 56 times by 1 test: connection->d_func()->dequeueRequest(socket);
Executed by:
  • tst_QNetworkReply
56
1077 if (reply) {
replyDescription
TRUEevaluated 92 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-92
1078 reply->setSpdyWasUsed(false);-
1079 Q_ASSERT(reply->d_func()->connectionChannel == this);-
1080 emit reply->encrypted();-
1081 }
executed 92 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
92
1082 if (reply)
replyDescription
TRUEevaluated 92 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-92
1083 sendRequest();
executed 92 times by 3 tests: sendRequest();
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
92
1084 }
executed 95 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
95
1085}-
1086-
1087void QHttpNetworkConnectionChannel::requeueSpdyRequests()-
1088{-
1089 QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();-
1090 for (int a = 0; a < spdyPairs.count(); ++a) {
a < spdyPairs.count()Description
TRUEnever evaluated
FALSEevaluated 85 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-85
1091 connection->d_func()->requeueRequest(spdyPairs.at(a));-
1092 }
never executed: end of block
0
1093 spdyRequestsToSend.clear();-
1094}
executed 85 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
85
1095-
1096void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error,-
1097 const char *message)-
1098{-
1099 if (reply)
replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1100 emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
never executed: reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
0
1101 QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();-
1102 for (int a = 0; a < spdyPairs.count(); ++a) {
a < spdyPairs.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1103 QHttpNetworkReply *currentReply = spdyPairs.at(a).second;-
1104 Q_ASSERT(currentReply);-
1105 emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));-
1106 }
never executed: end of block
0
1107}
never executed: end of block
0
1108-
1109void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)-
1110{-
1111 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 54 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
0-54
1112 return;
never executed: return;
0
1113 //QNetworkReply::NetworkError errorCode = QNetworkReply::ProtocolFailure;-
1114 // Also pause the connection because socket notifiers may fire while an user-
1115 // dialog is displaying-
1116 connection->d_func()->pauseConnection();-
1117 if (pendingEncrypt && !reply)
pendingEncryptDescription
TRUEevaluated 54 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEnever evaluated
!replyDescription
TRUEevaluated 48 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-54
1118 connection->d_func()->dequeueRequest(socket);
executed 48 times by 3 tests: connection->d_func()->dequeueRequest(socket);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
48
1119 if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP) {
connection->co...ectionTypeHTTPDescription
TRUEevaluated 47 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
7-47
1120 if (reply)
replyDescription
TRUEevaluated 45 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-45
1121 emit reply->sslErrors(errors);
executed 45 times by 3 tests: reply->sslErrors(errors);
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
45
1122 }
executed 47 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
47
1123#ifndef QT_NO_SSL-
1124 else { // SPDY-
1125 QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();-
1126 for (int a = 0; a < spdyPairs.count(); ++a) {
a < spdyPairs.count()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_Spdy
7
1127 // emit SSL errors for all replies-
1128 QHttpNetworkReply *currentReply = spdyPairs.at(a).second;-
1129 Q_ASSERT(currentReply);-
1130 emit currentReply->sslErrors(errors);-
1131 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_Spdy
7
1132 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_Spdy
7
1133#endif // QT_NO_SSL-
1134 connection->d_func()->resumeConnection();-
1135}
executed 54 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
54
1136-
1137void QHttpNetworkConnectionChannel::_q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)-
1138{-
1139 connection->d_func()->pauseConnection();-
1140-
1141 if (pendingEncrypt && !reply)
pendingEncryptDescription
TRUEnever evaluated
FALSEnever evaluated
!replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1142 connection->d_func()->dequeueRequest(socket);
never executed: connection->d_func()->dequeueRequest(socket);
0
1143-
1144 if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP) {
connection->co...ectionTypeHTTPDescription
TRUEnever evaluated
FALSEnever evaluated
0
1145 if (reply)
replyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1146 emit reply->preSharedKeyAuthenticationRequired(authenticator);
never executed: reply->preSharedKeyAuthenticationRequired(authenticator);
0
1147 } else {
never executed: end of block
0
1148 QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();-
1149 for (int a = 0; a < spdyPairs.count(); ++a) {
a < spdyPairs.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1150 // emit SSL errors for all replies-
1151 QHttpNetworkReply *currentReply = spdyPairs.at(a).second;-
1152 Q_ASSERT(currentReply);-
1153 emit currentReply->preSharedKeyAuthenticationRequired(authenticator);-
1154 }
never executed: end of block
0
1155 }
never executed: end of block
0
1156-
1157 connection->d_func()->resumeConnection();-
1158}
never executed: end of block
0
1159-
1160void QHttpNetworkConnectionChannel::_q_encryptedBytesWritten(qint64 bytes)-
1161{-
1162 Q_UNUSED(bytes);-
1163 // bytes have been written to the socket. write even more of them :)-
1164 if (isSocketWriting())
isSocketWriting()Description
TRUEevaluated 896 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1182 times by 3 tests
Evaluated by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
896-1182
1165 sendRequest();
executed 896 times by 1 test: sendRequest();
Executed by:
  • tst_QNetworkReply
896
1166 // otherwise we do nothing-
1167}
executed 2078 times by 3 tests: end of block
Executed by:
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_Spdy
2078
1168-
1169#endif-
1170-
1171void QHttpNetworkConnectionChannel::setConnection(QHttpNetworkConnection *c)-
1172{-
1173 // Inlining this function in the header leads to compiler error on-
1174 // release-armv5, on at least timebox 9.2 and 10.1.-
1175 connection = c;-
1176}
executed 3416 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
3416
1177-
1178QT_END_NAMESPACE-
1179-
1180#include "moc_qhttpnetworkconnectionchannel_p.cpp"-
1181-
1182#endif // QT_NO_HTTP-
Source codeSwitch to Preprocessed file

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