access/qhttpnetworkconnection.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtNetwork module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qhttpnetworkconnection_p.h" -
43#include <private/qabstractsocket_p.h> -
44#include "qhttpnetworkconnectionchannel_p.h" -
45#include "private/qnoncontiguousbytedevice_p.h" -
46#include <private/qnetworkrequest_p.h> -
47#include <private/qobject_p.h> -
48#include <private/qauthenticator_p.h> -
49#include "private/qhostinfo_p.h" -
50#include <qnetworkproxy.h> -
51#include <qauthenticator.h> -
52#include <qcoreapplication.h> -
53 -
54#include <qbuffer.h> -
55#include <qpair.h> -
56#include <qdebug.h> -
57 -
58#ifndef QT_NO_HTTP -
59 -
60#ifndef QT_NO_SSL -
61# include <private/qsslsocket_p.h> -
62# include <QtNetwork/qsslkey.h> -
63# include <QtNetwork/qsslcipher.h> -
64# include <QtNetwork/qsslconfiguration.h> -
65#endif -
66 -
67 -
68 -
69QT_BEGIN_NAMESPACE -
70 -
71const int QHttpNetworkConnectionPrivate::defaultChannelCount = 6; -
72 -
73// The pipeline length. So there will be 4 requests in flight. -
74const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3; -
75// Only re-fill the pipeline if there's defaultRePipelineLength slots free in the pipeline. -
76// This means that there are 2 requests in flight and 2 slots free that will be re-filled. -
77const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2; -
78 -
79 -
80QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt) -
81: state(RunningState), -
82 networkLayerState(Unknown), -
83 hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true), -
84 channelCount(defaultChannelCount) -
85#ifndef QT_NO_NETWORKPROXY -
86 , networkProxy(QNetworkProxy::NoProxy) -
87#endif -
88{ -
89 channels = new QHttpNetworkConnectionChannel[channelCount];
executed (the execution status of this line is deduced): channels = new QHttpNetworkConnectionChannel[channelCount];
-
90}
executed: }
Execution Count:507
507
91 -
92QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, quint16 port, bool encrypt) -
93: state(RunningState), networkLayerState(Unknown), -
94 hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true), -
95 channelCount(channelCount) -
96#ifndef QT_NO_NETWORKPROXY -
97 , networkProxy(QNetworkProxy::NoProxy) -
98#endif -
99{ -
100 channels = new QHttpNetworkConnectionChannel[channelCount];
never executed (the execution status of this line is deduced): channels = new QHttpNetworkConnectionChannel[channelCount];
-
101}
never executed: }
0
102 -
103 -
104 -
105QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() -
106{ -
107 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:3042
yes
Evaluation Count:507
507-3042
108 if (channels[i].socket) {
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:531
yes
Evaluation Count:2511
531-2511
109 channels[i].socket->close();
executed (the execution status of this line is deduced): channels[i].socket->close();
-
110 delete channels[i].socket;
executed (the execution status of this line is deduced): delete channels[i].socket;
-
111 }
executed: }
Execution Count:531
531
112 }
executed: }
Execution Count:3042
3042
113 delete []channels;
executed (the execution status of this line is deduced): delete []channels;
-
114}
executed: }
Execution Count:507
507
115 -
116void QHttpNetworkConnectionPrivate::init() -
117{ -
118 Q_Q(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
119 for (int i = 0; i < channelCount; i++) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:3042
yes
Evaluation Count:507
507-3042
120 channels[i].setConnection(this->q_func());
executed (the execution status of this line is deduced): channels[i].setConnection(this->q_func());
-
121 channels[i].ssl = encrypt;
executed (the execution status of this line is deduced): channels[i].ssl = encrypt;
-
122#ifndef QT_NO_BEARERMANAGEMENT -
123 //push session down to channels -
124 channels[i].networkSession = networkSession;
executed (the execution status of this line is deduced): channels[i].networkSession = networkSession;
-
125#endif -
126 }
executed: }
Execution Count:3042
3042
127 -
128 delayedConnectionTimer.setSingleShot(true);
executed (the execution status of this line is deduced): delayedConnectionTimer.setSingleShot(true);
-
129 QObject::connect(&delayedConnectionTimer, SIGNAL(timeout()), q, SLOT(_q_connectDelayedChannel()));
executed (the execution status of this line is deduced): QObject::connect(&delayedConnectionTimer, "2""timeout()", q, "1""_q_connectDelayedChannel()");
-
130}
executed: }
Execution Count:507
507
131 -
132void QHttpNetworkConnectionPrivate::pauseConnection() -
133{ -
134 state = PausedState;
executed (the execution status of this line is deduced): state = PausedState;
-
135 -
136 // Disable all socket notifiers -
137 for (int i = 0; i < channelCount; i++) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:1380
yes
Evaluation Count:230
230-1380
138 if (channels[i].socket) {
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:1127
253-1127
139#ifndef QT_NO_SSL -
140 if (encrypt)
evaluated: encrypt
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:182
71-182
141 QSslSocketPrivate::pauseSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));
executed: QSslSocketPrivate::pauseSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));
Execution Count:71
71
142 else -
143#endif -
144 QAbstractSocketPrivate::pauseSocketNotifiers(channels[i].socket);
executed: QAbstractSocketPrivate::pauseSocketNotifiers(channels[i].socket);
Execution Count:182
182
145 } -
146 }
executed: }
Execution Count:1380
1380
147}
executed: }
Execution Count:230
230
148 -
149void QHttpNetworkConnectionPrivate::resumeConnection() -
150{ -
151 state = RunningState;
executed (the execution status of this line is deduced): state = RunningState;
-
152 // Enable all socket notifiers -
153 for (int i = 0; i < channelCount; i++) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:1380
yes
Evaluation Count:230
230-1380
154 if (channels[i].socket) {
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:1127
253-1127
155#ifndef QT_NO_SSL -
156 if (encrypt)
evaluated: encrypt
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:182
71-182
157 QSslSocketPrivate::resumeSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));
executed: QSslSocketPrivate::resumeSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket));
Execution Count:71
71
158 else -
159#endif -
160 QAbstractSocketPrivate::resumeSocketNotifiers(channels[i].socket);
executed: QAbstractSocketPrivate::resumeSocketNotifiers(channels[i].socket);
Execution Count:182
182
161 -
162 // Resume pending upload if needed -
163 if (channels[i].state == QHttpNetworkConnectionChannel::WritingState)
partially evaluated: channels[i].state == QHttpNetworkConnectionChannel::WritingState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:253
0-253
164 QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection);
never executed: QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection);
0
165 }
executed: }
Execution Count:253
253
166 }
executed: }
Execution Count:1380
1380
167 -
168 // queue _q_startNextRequest -
169 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
-
170}
executed: }
Execution Count:230
230
171 -
172int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const -
173{ -
174 for (int i = 0; i < channelCount; ++i)
partially evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:6476
no
Evaluation Count:0
0-6476
175 if (channels[i].socket == socket)
evaluated: channels[i].socket == socket
TRUEFALSE
yes
Evaluation Count:3157
yes
Evaluation Count:3319
3157-3319
176 return i;
executed: return i;
Execution Count:3157
3157
177 -
178 qFatal("Called with unknown socket object.");
never executed (the execution status of this line is deduced): QMessageLogger("access/qhttpnetworkconnection.cpp", 178, __PRETTY_FUNCTION__).fatal("Called with unknown socket object.");
-
179 return 0;
never executed: return 0;
0
180} -
181 -
182// If the connection is in the InProgress state channel errors should not always be -
183// emitted. This function will check the status of the connection channels if we -
184// have not decided the networkLayerState and will return true if the channel error -
185// should be emitted by the channel. -
186bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *socket) -
187{ -
188 Q_Q(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
189 -
190 bool emitError = true;
executed (the execution status of this line is deduced): bool emitError = true;
-
191 int i = indexOf(socket);
executed (the execution status of this line is deduced): int i = indexOf(socket);
-
192 int otherSocket = (i == 0 ? 1 : 0);
partially evaluated: i == 0
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
0-47
193 -
194 // If the IPv4 connection still isn't started we need to start it now. -
195 if (delayedConnectionTimer.isActive()) {
partially evaluated: delayedConnectionTimer.isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
196 delayedConnectionTimer.stop();
never executed (the execution status of this line is deduced): delayedConnectionTimer.stop();
-
197 channels[otherSocket].ensureConnection();
never executed (the execution status of this line is deduced): channels[otherSocket].ensureConnection();
-
198 }
never executed: }
0
199 -
200 if (channelCount == 1) {
partially evaluated: channelCount == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
201 if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress)
never evaluated: networkLayerState == QHttpNetworkConnectionPrivate::InProgress
0
202 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
never executed: networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
0
203 channels[0].close();
never executed (the execution status of this line is deduced): channels[0].close();
-
204 emitError = true;
never executed (the execution status of this line is deduced): emitError = true;
-
205 } else {
never executed: }
0
206 if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) {
partially evaluated: networkLayerState == QHttpNetworkConnectionPrivate::InProgress
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
207 if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) {
never evaluated: channels[otherSocket].isSocketBusy()
never evaluated: (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)
0
208 // this was the first socket to fail. -
209 channels[i].close();
never executed (the execution status of this line is deduced): channels[i].close();
-
210 emitError = false;
never executed (the execution status of this line is deduced): emitError = false;
-
211 }
never executed: }
0
212 else { -
213 // Both connection attempts has failed. -
214 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
never executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
-
215 channels[i].close();
never executed (the execution status of this line is deduced): channels[i].close();
-
216 emitError = true;
never executed (the execution status of this line is deduced): emitError = true;
-
217 }
never executed: }
0
218 } else { -
219 if (((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol))
partially evaluated: (networkLayerState == QHttpNetworkConnectionPrivate::IPv4)
TRUEFALSE
yes
Evaluation Count:47
no
Evaluation Count:0
partially evaluated: (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
220 || ((networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol))) {
partially evaluated: (networkLayerState == QHttpNetworkConnectionPrivate::IPv6)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
never evaluated: (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)
0-47
221 // First connection worked so this is the second one to complete and it failed. -
222 channels[i].close();
never executed (the execution status of this line is deduced): channels[i].close();
-
223 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
224 emitError = false;
never executed (the execution status of this line is deduced): emitError = false;
-
225 }
never executed: }
0
226 if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown)
partially evaluated: networkLayerState == QHttpNetworkConnectionPrivate::Unknown
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:47
0-47
227 qWarning() << "We got a connection error when networkLayerState is Unknown";
never executed: QMessageLogger("access/qhttpnetworkconnection.cpp", 227, __PRETTY_FUNCTION__).warning() << "We got a connection error when networkLayerState is Unknown";
0
228 }
executed: }
Execution Count:47
47
229 } -
230 return emitError;
executed: return emitError;
Execution Count:47
47
231} -
232 -
233 -
234qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const -
235{ -
236 return reply.d_func()->responseData.byteAmount();
never executed: return reply.d_func()->responseData.byteAmount();
0
237} -
238 -
239qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const -
240{ -
241 return reply.d_func()->responseData.sizeNextBlock();
never executed: return reply.d_func()->responseData.sizeNextBlock();
0
242} -
243 -
244void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) -
245{ -
246 QHttpNetworkRequest &request = messagePair.first;
executed (the execution status of this line is deduced): QHttpNetworkRequest &request = messagePair.first;
-
247 QHttpNetworkReply *reply = messagePair.second;
executed (the execution status of this line is deduced): QHttpNetworkReply *reply = messagePair.second;
-
248 -
249 // add missing fields for the request -
250 QByteArray value;
executed (the execution status of this line is deduced): QByteArray value;
-
251 // check if Content-Length is provided -
252 QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
executed (the execution status of this line is deduced): QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice();
-
253 if (uploadByteDevice) {
evaluated: uploadByteDevice
TRUEFALSE
yes
Evaluation Count:179
yes
Evaluation Count:509
179-509
254 if (request.contentLength() != -1 && uploadByteDevice->size() != -1) {
evaluated: request.contentLength() != -1
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:67
evaluated: uploadByteDevice->size() != -1
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:1
1-112
255 // both values known, take the smaller one. -
256 request.setContentLength(qMin(uploadByteDevice->size(), request.contentLength()));
executed (the execution status of this line is deduced): request.setContentLength(qMin(uploadByteDevice->size(), request.contentLength()));
-
257 } else if (request.contentLength() == -1 && uploadByteDevice->size() != -1) {
executed: }
Execution Count:111
evaluated: request.contentLength() == -1
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:1
partially evaluated: uploadByteDevice->size() != -1
TRUEFALSE
yes
Evaluation Count:67
no
Evaluation Count:0
0-111
258 // content length not supplied by user, but the upload device knows it -
259 request.setContentLength(uploadByteDevice->size());
executed (the execution status of this line is deduced): request.setContentLength(uploadByteDevice->size());
-
260 } else if (request.contentLength() != -1 && uploadByteDevice->size() == -1) {
executed: }
Execution Count:67
partially evaluated: request.contentLength() != -1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: uploadByteDevice->size() == -1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-67
261 // everything OK, the user supplied us the contentLength -
262 } else if (request.contentLength() == -1 && uploadByteDevice->size() == -1) {
executed: }
Execution Count:1
never evaluated: request.contentLength() == -1
never evaluated: uploadByteDevice->size() == -1
0-1
263 qFatal("QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given");
never executed (the execution status of this line is deduced): QMessageLogger("access/qhttpnetworkconnection.cpp", 263, __PRETTY_FUNCTION__).fatal("QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given");
-
264 }
never executed: }
0
265 } -
266 // set the Connection/Proxy-Connection: Keep-Alive headers -
267#ifndef QT_NO_NETWORKPROXY -
268 if (networkProxy.type() == QNetworkProxy::HttpCachingProxy) {
evaluated: networkProxy.type() == QNetworkProxy::HttpCachingProxy
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:680
8-680
269 value = request.headerField("proxy-connection");
executed (the execution status of this line is deduced): value = request.headerField("proxy-connection");
-
270 if (value.isEmpty())
partially evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
271 request.setHeaderField("Proxy-Connection", "Keep-Alive");
executed: request.setHeaderField("Proxy-Connection", "Keep-Alive");
Execution Count:8
8
272 } else {
executed: }
Execution Count:8
8
273#endif -
274 value = request.headerField("connection");
executed (the execution status of this line is deduced): value = request.headerField("connection");
-
275 if (value.isEmpty())
partially evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:680
no
Evaluation Count:0
0-680
276 request.setHeaderField("Connection", "Keep-Alive");
executed: request.setHeaderField("Connection", "Keep-Alive");
Execution Count:680
680
277#ifndef QT_NO_NETWORKPROXY -
278 }
executed: }
Execution Count:680
680
279#endif -
280 -
281 // If the request had a accept-encoding set, we better not mess -
282 // with it. If it was not set, we announce that we understand gzip -
283 // and remember this fact in request.d->autoDecompress so that -
284 // we can later decompress the HTTP reply if it has such an -
285 // encoding. -
286 value = request.headerField("accept-encoding");
executed (the execution status of this line is deduced): value = request.headerField("accept-encoding");
-
287 if (value.isEmpty()) {
partially evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:688
no
Evaluation Count:0
0-688
288#ifndef QT_NO_COMPRESS -
289 request.setHeaderField("Accept-Encoding", "gzip, deflate");
executed (the execution status of this line is deduced): request.setHeaderField("Accept-Encoding", "gzip, deflate");
-
290 request.d->autoDecompress = true;
executed (the execution status of this line is deduced): request.d->autoDecompress = true;
-
291#else -
292 // if zlib is not available set this to false always -
293 request.d->autoDecompress = false; -
294#endif -
295 }
executed: }
Execution Count:688
688
296 -
297 // some websites mandate an accept-language header and fail -
298 // if it is not sent. This is a problem with the website and -
299 // not with us, but we work around this by setting -
300 // one always. -
301 value = request.headerField("accept-language");
executed (the execution status of this line is deduced): value = request.headerField("accept-language");
-
302 if (value.isEmpty()) {
partially evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:688
no
Evaluation Count:0
0-688
303 QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-'));
executed (the execution status of this line is deduced): QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-'));
-
304 QString acceptLanguage;
executed (the execution status of this line is deduced): QString acceptLanguage;
-
305 if (systemLocale == QLatin1String("C"))
partially evaluated: systemLocale == QLatin1String("C")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:688
0-688
306 acceptLanguage = QString::fromLatin1("en,*");
never executed: acceptLanguage = QString::fromLatin1("en,*");
0
307 else if (systemLocale.startsWith(QLatin1String("en-")))
partially evaluated: systemLocale.startsWith(QLatin1String("en-"))
TRUEFALSE
yes
Evaluation Count:688
no
Evaluation Count:0
0-688
308 acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale);
executed: acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale);
Execution Count:688
688
309 else -
310 acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale);
never executed: acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale);
0
311 request.setHeaderField("Accept-Language", acceptLanguage.toLatin1());
executed (the execution status of this line is deduced): request.setHeaderField("Accept-Language", acceptLanguage.toLatin1());
-
312 }
executed: }
Execution Count:688
688
313 -
314 // set the User Agent -
315 value = request.headerField("user-agent");
executed (the execution status of this line is deduced): value = request.headerField("user-agent");
-
316 if (value.isEmpty())
evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:684
yes
Evaluation Count:4
4-684
317 request.setHeaderField("User-Agent", "Mozilla/5.0");
executed: request.setHeaderField("User-Agent", "Mozilla/5.0");
Execution Count:684
684
318 // set the host -
319 value = request.headerField("host");
executed (the execution status of this line is deduced): value = request.headerField("host");
-
320 if (value.isEmpty()) {
evaluated: value.isEmpty()
TRUEFALSE
yes
Evaluation Count:687
yes
Evaluation Count:1
1-687
321 QHostAddress add;
executed (the execution status of this line is deduced): QHostAddress add;
-
322 QByteArray host;
executed (the execution status of this line is deduced): QByteArray host;
-
323 if (add.setAddress(hostName)) {
evaluated: add.setAddress(hostName)
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:657
30-657
324 if (add.protocol() == QAbstractSocket::IPv6Protocol)
evaluated: add.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:29
1-29
325 host = "[" + hostName.toLatin1() + "]";//format the ipv6 in the standard way
executed: host = "[" + hostName.toLatin1() + "]";
Execution Count:1
1
326 else -
327 host = hostName.toLatin1();
executed: host = hostName.toLatin1();
Execution Count:29
29
328 -
329 } else { -
330 host = QUrl::toAce(hostName);
executed (the execution status of this line is deduced): host = QUrl::toAce(hostName);
-
331 }
executed: }
Execution Count:657
657
332 -
333 int port = request.url().port();
executed (the execution status of this line is deduced): int port = request.url().port();
-
334 if (port != -1) {
evaluated: port != -1
TRUEFALSE
yes
Evaluation Count:148
yes
Evaluation Count:539
148-539
335 host += ':';
executed (the execution status of this line is deduced): host += ':';
-
336 host += QByteArray::number(port);
executed (the execution status of this line is deduced): host += QByteArray::number(port);
-
337 }
executed: }
Execution Count:148
148
338 -
339 request.setHeaderField("Host", host);
executed (the execution status of this line is deduced): request.setHeaderField("Host", host);
-
340 }
executed: }
Execution Count:687
687
341 -
342 reply->d_func()->requestIsPrepared = true;
executed (the execution status of this line is deduced): reply->d_func()->requestIsPrepared = true;
-
343}
executed: }
Execution Count:688
688
344 -
345 -
346 -
347 -
348void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket, -
349 QHttpNetworkReply *reply, -
350 QNetworkReply::NetworkError errorCode) -
351{ -
352 Q_Q(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
353 -
354 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
355 if (socket)
evaluated: socket
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
356 i = indexOf(socket);
executed: i = indexOf(socket);
Execution Count:4
4
357 -
358 if (reply) {
partially evaluated: reply
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
359 // this error matters only to this reply -
360 reply->d_func()->errorString = errorDetail(errorCode, socket);
executed (the execution status of this line is deduced): reply->d_func()->errorString = errorDetail(errorCode, socket);
-
361 emit reply->finishedWithError(errorCode, reply->d_func()->errorString);
executed (the execution status of this line is deduced): reply->finishedWithError(errorCode, reply->d_func()->errorString);
-
362 // remove the corrupt data if any -
363 reply->d_func()->eraseData();
executed (the execution status of this line is deduced): reply->d_func()->eraseData();
-
364 -
365 // Clean the channel -
366 channels[i].close();
executed (the execution status of this line is deduced): channels[i].close();
-
367 channels[i].reply = 0;
executed (the execution status of this line is deduced): channels[i].reply = 0;
-
368 channels[i].request = QHttpNetworkRequest();
executed (the execution status of this line is deduced): channels[i].request = QHttpNetworkRequest();
-
369 if (socket)
evaluated: socket
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
370 channels[i].requeueCurrentlyPipelinedRequests();
executed: channels[i].requeueCurrentlyPipelinedRequests();
Execution Count:4
4
371 -
372 // send the next request -
373 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
374 }
executed: }
Execution Count:5
5
375}
executed: }
Execution Count:5
5
376 -
377void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy) -
378{ -
379 Q_ASSERT(auth);
executed (the execution status of this line is deduced): qt_noop();
-
380 -
381 // NTLM is a multi phase authentication. Copying credentials between authenticators would mess things up. -
382 if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm)
evaluated: !isProxy
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:59
partially evaluated: channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:124
0-124
383 return;
never executed: return;
0
384 if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm)
evaluated: isProxy
TRUEFALSE
yes
Evaluation Count:59
yes
Evaluation Count:124
partially evaluated: channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:59
0-124
385 return;
never executed: return;
0
386 -
387 -
388 // select another channel -
389 QAuthenticator* otherAuth = 0;
executed (the execution status of this line is deduced): QAuthenticator* otherAuth = 0;
-
390 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:1098
yes
Evaluation Count:183
183-1098
391 if (i == fromChannel)
evaluated: i == fromChannel
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:915
183-915
392 continue;
executed: continue;
Execution Count:183
183
393 if (isProxy)
evaluated: isProxy
TRUEFALSE
yes
Evaluation Count:295
yes
Evaluation Count:620
295-620
394 otherAuth = &channels[i].proxyAuthenticator;
executed: otherAuth = &channels[i].proxyAuthenticator;
Execution Count:295
295
395 else -
396 otherAuth = &channels[i].authenticator;
executed: otherAuth = &channels[i].authenticator;
Execution Count:620
620
397 // if the credentials are different, copy them -
398 if (otherAuth->user().compare(auth->user()))
evaluated: otherAuth->user().compare(auth->user())
TRUEFALSE
yes
Evaluation Count:700
yes
Evaluation Count:215
215-700
399 otherAuth->setUser(auth->user());
executed: otherAuth->setUser(auth->user());
Execution Count:700
700
400 if (otherAuth->password().compare(auth->password()))
evaluated: otherAuth->password().compare(auth->password())
TRUEFALSE
yes
Evaluation Count:710
yes
Evaluation Count:205
205-710
401 otherAuth->setPassword(auth->password());
executed: otherAuth->setPassword(auth->password());
Execution Count:710
710
402 }
executed: }
Execution Count:915
915
403}
executed: }
Execution Count:183
183
404 -
405 -
406// handles the authentication for one channel and eventually re-starts the other channels -
407bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, -
408 bool isProxy, bool &resend) -
409{ -
410 Q_ASSERT(socket);
executed (the execution status of this line is deduced): qt_noop();
-
411 Q_ASSERT(reply);
executed (the execution status of this line is deduced): qt_noop();
-
412 -
413 resend = false;
executed (the execution status of this line is deduced): resend = false;
-
414 //create the response header to be used with QAuthenticatorPrivate. -
415 QList<QPair<QByteArray, QByteArray> > fields = reply->header();
executed (the execution status of this line is deduced): QList<QPair<QByteArray, QByteArray> > fields = reply->header();
-
416 -
417 //find out the type of authentication protocol requested. -
418 QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy);
executed (the execution status of this line is deduced): QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy);
-
419 if (authMethod != QAuthenticatorPrivate::None) {
evaluated: authMethod != QAuthenticatorPrivate::None
TRUEFALSE
yes
Evaluation Count:332
yes
Evaluation Count:3
3-332
420 int i = indexOf(socket);
executed (the execution status of this line is deduced): int i = indexOf(socket);
-
421 //Use a single authenticator for all domains. ### change later to use domain/realm -
422 QAuthenticator* auth = 0;
executed (the execution status of this line is deduced): QAuthenticator* auth = 0;
-
423 if (isProxy) {
evaluated: isProxy
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:275
57-275
424 auth = &channels[i].proxyAuthenticator;
executed (the execution status of this line is deduced): auth = &channels[i].proxyAuthenticator;
-
425 channels[i].proxyAuthMethod = authMethod;
executed (the execution status of this line is deduced): channels[i].proxyAuthMethod = authMethod;
-
426 } else {
executed: }
Execution Count:57
57
427 auth = &channels[i].authenticator;
executed (the execution status of this line is deduced): auth = &channels[i].authenticator;
-
428 channels[i].authMethod = authMethod;
executed (the execution status of this line is deduced): channels[i].authMethod = authMethod;
-
429 }
executed: }
Execution Count:275
275
430 //proceed with the authentication. -
431 if (auth->isNull())
partially evaluated: auth->isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:332
0-332
432 auth->detach();
never executed: auth->detach();
0
433 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth);
executed (the execution status of this line is deduced): QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth);
-
434 priv->parseHttpResponse(fields, isProxy);
executed (the execution status of this line is deduced): priv->parseHttpResponse(fields, isProxy);
-
435 -
436 if (priv->phase == QAuthenticatorPrivate::Done) {
evaluated: priv->phase == QAuthenticatorPrivate::Done
TRUEFALSE
yes
Evaluation Count:163
yes
Evaluation Count:169
163-169
437 pauseConnection();
executed (the execution status of this line is deduced): pauseConnection();
-
438 if (!isProxy) {
evaluated: !isProxy
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:29
29-134
439 if (channels[i].authenticationCredentialsSent) {
evaluated: channels[i].authenticationCredentialsSent
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:88
46-88
440 auth->detach();
executed (the execution status of this line is deduced): auth->detach();
-
441 priv = QAuthenticatorPrivate::getPrivate(*auth);
executed (the execution status of this line is deduced): priv = QAuthenticatorPrivate::getPrivate(*auth);
-
442 priv->hasFailed = true;
executed (the execution status of this line is deduced): priv->hasFailed = true;
-
443 priv->phase = QAuthenticatorPrivate::Done;
executed (the execution status of this line is deduced): priv->phase = QAuthenticatorPrivate::Done;
-
444 channels[i].authenticationCredentialsSent = false;
executed (the execution status of this line is deduced): channels[i].authenticationCredentialsSent = false;
-
445 }
executed: }
Execution Count:46
46
446 emit reply->authenticationRequired(reply->request(), auth);
executed (the execution status of this line is deduced): reply->authenticationRequired(reply->request(), auth);
-
447#ifndef QT_NO_NETWORKPROXY -
448 } else {
executed: }
Execution Count:134
134
449 if (channels[i].proxyCredentialsSent) {
evaluated: channels[i].proxyCredentialsSent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:27
2-27
450 auth->detach();
executed (the execution status of this line is deduced): auth->detach();
-
451 priv = QAuthenticatorPrivate::getPrivate(*auth);
executed (the execution status of this line is deduced): priv = QAuthenticatorPrivate::getPrivate(*auth);
-
452 priv->hasFailed = true;
executed (the execution status of this line is deduced): priv->hasFailed = true;
-
453 priv->phase = QAuthenticatorPrivate::Done;
executed (the execution status of this line is deduced): priv->phase = QAuthenticatorPrivate::Done;
-
454 channels[i].proxyCredentialsSent = false;
executed (the execution status of this line is deduced): channels[i].proxyCredentialsSent = false;
-
455 }
executed: }
Execution Count:2
2
456 emit reply->proxyAuthenticationRequired(networkProxy, auth);
executed (the execution status of this line is deduced): reply->proxyAuthenticationRequired(networkProxy, auth);
-
457#endif -
458 }
executed: }
Execution Count:29
29
459 resumeConnection();
executed (the execution status of this line is deduced): resumeConnection();
-
460 -
461 if (priv->phase != QAuthenticatorPrivate::Done) {
evaluated: priv->phase != QAuthenticatorPrivate::Done
TRUEFALSE
yes
Evaluation Count:132
yes
Evaluation Count:31
31-132
462 // send any pending requests -
463 copyCredentials(i, auth, isProxy);
executed (the execution status of this line is deduced): copyCredentials(i, auth, isProxy);
-
464 }
executed: }
Execution Count:132
132
465 } else if (priv->phase == QAuthenticatorPrivate::Start) {
executed: }
Execution Count:163
partially evaluated: priv->phase == QAuthenticatorPrivate::Start
TRUEFALSE
yes
Evaluation Count:169
no
Evaluation Count:0
0-169
466 // If the url's authenticator has a 'user' set we will end up here (phase is only set to 'Done' by -
467 // parseHttpResponse above if 'user' is empty). So if credentials were supplied with the request, -
468 // such as in the case of an XMLHttpRequest, this is our only opportunity to cache them. -
469 emit reply->cacheCredentials(reply->request(), auth);
executed (the execution status of this line is deduced): reply->cacheCredentials(reply->request(), auth);
-
470 }
executed: }
Execution Count:169
169
471 // - Changing values in QAuthenticator will reset the 'phase'. Therefore if it is still "Done" -
472 // then nothing was filled in by the user or the cache -
473 // - If withCredentials has been set to false (e.g. by Qt WebKit for a cross-origin XMLHttpRequest) then -
474 // we need to bail out if authentication is required. -
475 if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) {
evaluated: priv->phase == QAuthenticatorPrivate::Done
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:301
partially evaluated: !reply->request().withCredentials()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:301
0-301
476 // Reset authenticator so the next request on that channel does not get messed up -
477 auth = 0;
executed (the execution status of this line is deduced): auth = 0;
-
478 if (isProxy)
evaluated: isProxy
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:28
3-28
479 channels[i].proxyAuthenticator = QAuthenticator();
executed: channels[i].proxyAuthenticator = QAuthenticator();
Execution Count:3
3
480 else -
481 channels[i].authenticator = QAuthenticator();
executed: channels[i].authenticator = QAuthenticator();
Execution Count:28
28
482 -
483 // authentication is cancelled, send the current contents to the user. -
484 emit channels[i].reply->headerChanged();
executed (the execution status of this line is deduced): channels[i].reply->headerChanged();
-
485 emit channels[i].reply->readyRead();
executed (the execution status of this line is deduced): channels[i].reply->readyRead();
-
486 QNetworkReply::NetworkError errorCode =
executed (the execution status of this line is deduced): QNetworkReply::NetworkError errorCode =
-
487 isProxy
evaluated: isProxy
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:28
3-28
488 ? QNetworkReply::ProxyAuthenticationRequiredError
executed (the execution status of this line is deduced): ? QNetworkReply::ProxyAuthenticationRequiredError
-
489 : QNetworkReply::AuthenticationRequiredError;
executed (the execution status of this line is deduced): : QNetworkReply::AuthenticationRequiredError;
-
490 reply->d_func()->errorString = errorDetail(errorCode, socket);
executed (the execution status of this line is deduced): reply->d_func()->errorString = errorDetail(errorCode, socket);
-
491 emit reply->finishedWithError(errorCode, reply->d_func()->errorString);
executed (the execution status of this line is deduced): reply->finishedWithError(errorCode, reply->d_func()->errorString);
-
492 // ### at this point the reply could be deleted -
493 return true;
executed: return true;
Execution Count:31
31
494 } -
495 //resend the request -
496 resend = true;
executed (the execution status of this line is deduced): resend = true;
-
497 return true;
executed: return true;
Execution Count:301
301
498 } -
499 return false;
executed: return false;
Execution Count:3
3
500} -
501 -
502void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request) -
503{ -
504 Q_ASSERT(socket);
executed (the execution status of this line is deduced): qt_noop();
-
505 -
506 int i = indexOf(socket);
executed (the execution status of this line is deduced): int i = indexOf(socket);
-
507 -
508 // Send "Authorization" header, but not if it's NTLM and the socket is already authenticated. -
509 if (channels[i].authMethod != QAuthenticatorPrivate::None) {
evaluated: channels[i].authMethod != QAuthenticatorPrivate::None
TRUEFALSE
yes
Evaluation Count:157
yes
Evaluation Count:691
157-691
510 if (!(channels[i].authMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) {
partially evaluated: channels[i].authMethod == QAuthenticatorPrivate::Ntlm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:157
never evaluated: channels[i].lastStatus != 401
0-157
511 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
executed (the execution status of this line is deduced): QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator);
-
512 if (priv && priv->method != QAuthenticatorPrivate::None) {
partially evaluated: priv
TRUEFALSE
yes
Evaluation Count:157
no
Evaluation Count:0
evaluated: priv->method != QAuthenticatorPrivate::None
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:16
0-157
513 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
executed (the execution status of this line is deduced): QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
-
514 request.setHeaderField("Authorization", response);
executed (the execution status of this line is deduced): request.setHeaderField("Authorization", response);
-
515 channels[i].authenticationCredentialsSent = true;
executed (the execution status of this line is deduced): channels[i].authenticationCredentialsSent = true;
-
516 }
executed: }
Execution Count:141
141
517 }
executed: }
Execution Count:157
157
518 }
executed: }
Execution Count:157
157
519 -
520 // Send "Proxy-Authorization" header, but not if it's NTLM and the socket is already authenticated. -
521 if (channels[i].proxyAuthMethod != QAuthenticatorPrivate::None) {
evaluated: channels[i].proxyAuthMethod != QAuthenticatorPrivate::None
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:805
43-805
522 if (!(channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) {
partially evaluated: channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
never evaluated: channels[i].lastStatus != 407
0-43
523 QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
executed (the execution status of this line is deduced): QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator);
-
524 if (priv && priv->method != QAuthenticatorPrivate::None) {
partially evaluated: priv
TRUEFALSE
yes
Evaluation Count:43
no
Evaluation Count:0
evaluated: priv->method != QAuthenticatorPrivate::None
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:2
0-43
525 QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
executed (the execution status of this line is deduced): QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false));
-
526 request.setHeaderField("Proxy-Authorization", response);
executed (the execution status of this line is deduced): request.setHeaderField("Proxy-Authorization", response);
-
527 channels[i].proxyCredentialsSent = true;
executed (the execution status of this line is deduced): channels[i].proxyCredentialsSent = true;
-
528 }
executed: }
Execution Count:41
41
529 }
executed: }
Execution Count:43
43
530 }
executed: }
Execution Count:43
43
531}
executed: }
Execution Count:848
848
532 -
533QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetworkRequest &request) -
534{ -
535 Q_Q(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
536 -
537 // The reply component of the pair is created initially. -
538 QHttpNetworkReply *reply = new QHttpNetworkReply(request.url());
executed (the execution status of this line is deduced): QHttpNetworkReply *reply = new QHttpNetworkReply(request.url());
-
539 reply->setRequest(request);
executed (the execution status of this line is deduced): reply->setRequest(request);
-
540 reply->d_func()->connection = q;
executed (the execution status of this line is deduced): reply->d_func()->connection = q;
-
541 reply->d_func()->connectionChannel = &channels[0]; // will have the correct one set later
executed (the execution status of this line is deduced): reply->d_func()->connectionChannel = &channels[0];
-
542 HttpMessagePair pair = qMakePair(request, reply);
executed (the execution status of this line is deduced): HttpMessagePair pair = qMakePair(request, reply);
-
543 -
544 switch (request.priority()) { -
545 case QHttpNetworkRequest::HighPriority: -
546 highPriorityQueue.prepend(pair);
never executed (the execution status of this line is deduced): highPriorityQueue.prepend(pair);
-
547 break;
never executed: break;
0
548 case QHttpNetworkRequest::NormalPriority: -
549 case QHttpNetworkRequest::LowPriority: -
550 lowPriorityQueue.prepend(pair);
executed (the execution status of this line is deduced): lowPriorityQueue.prepend(pair);
-
551 break;
executed: break;
Execution Count:694
694
552 } -
553 -
554 // For Happy Eyeballs the networkLayerState is set to Unknown -
555 // untill we have started the first connection attempt. So no -
556 // request will be started untill we know if IPv4 or IPv6 -
557 // should be used. -
558 if (networkLayerState == Unknown) {
evaluated: networkLayerState == Unknown
TRUEFALSE
yes
Evaluation Count:507
yes
Evaluation Count:187
187-507
559 startHostInfoLookup();
executed (the execution status of this line is deduced): startHostInfoLookup();
-
560 } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) {
executed: }
Execution Count:507
partially evaluated: networkLayerState == IPv4
TRUEFALSE
yes
Evaluation Count:187
no
Evaluation Count:0
never evaluated: networkLayerState == IPv6
0-507
561 // this used to be called via invokeMethod and a QueuedConnection -
562 // It is the only place _q_startNextRequest is called directly without going -
563 // through the event loop using a QueuedConnection. -
564 // This is dangerous because of recursion that might occur when emitting -
565 // signals as DirectConnection from this code path. Therefore all signal -
566 // emissions that can come out from this code path need to -
567 // be QueuedConnection. -
568 // We are currently trying to fine-tune this. -
569 _q_startNextRequest();
executed (the execution status of this line is deduced): _q_startNextRequest();
-
570 }
executed: }
Execution Count:187
187
571 return reply;
executed: return reply;
Execution Count:694
694
572} -
573 -
574void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair) -
575{ -
576 Q_Q(QHttpNetworkConnection);
never executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
577 -
578 QHttpNetworkRequest request = pair.first;
never executed (the execution status of this line is deduced): QHttpNetworkRequest request = pair.first;
-
579 switch (request.priority()) { -
580 case QHttpNetworkRequest::HighPriority: -
581 highPriorityQueue.prepend(pair);
never executed (the execution status of this line is deduced): highPriorityQueue.prepend(pair);
-
582 break;
never executed: break;
0
583 case QHttpNetworkRequest::NormalPriority: -
584 case QHttpNetworkRequest::LowPriority: -
585 lowPriorityQueue.prepend(pair);
never executed (the execution status of this line is deduced): lowPriorityQueue.prepend(pair);
-
586 break;
never executed: break;
0
587 } -
588 -
589 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
590}
never executed: }
0
591 -
592bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket) -
593{ -
594 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
595 if (socket)
evaluated: socket
TRUEFALSE
yes
Evaluation Count:711
yes
Evaluation Count:1
1-711
596 i = indexOf(socket);
executed: i = indexOf(socket);
Execution Count:711
711
597 -
598 if (!highPriorityQueue.isEmpty()) {
partially evaluated: !highPriorityQueue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:712
0-712
599 // remove from queue before sendRequest! else we might pipeline the same request again -
600 HttpMessagePair messagePair = highPriorityQueue.takeLast();
never executed (the execution status of this line is deduced): HttpMessagePair messagePair = highPriorityQueue.takeLast();
-
601 if (!messagePair.second->d_func()->requestIsPrepared)
never evaluated: !messagePair.second->d_func()->requestIsPrepared
0
602 prepareRequest(messagePair);
never executed: prepareRequest(messagePair);
0
603 channels[i].request = messagePair.first;
never executed (the execution status of this line is deduced): channels[i].request = messagePair.first;
-
604 channels[i].reply = messagePair.second;
never executed (the execution status of this line is deduced): channels[i].reply = messagePair.second;
-
605 return true;
never executed: return true;
0
606 } -
607 -
608 if (!lowPriorityQueue.isEmpty()) {
evaluated: !lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:678
yes
Evaluation Count:34
34-678
609 // remove from queue before sendRequest! else we might pipeline the same request again -
610 HttpMessagePair messagePair = lowPriorityQueue.takeLast();
executed (the execution status of this line is deduced): HttpMessagePair messagePair = lowPriorityQueue.takeLast();
-
611 if (!messagePair.second->d_func()->requestIsPrepared)
partially evaluated: !messagePair.second->d_func()->requestIsPrepared
TRUEFALSE
yes
Evaluation Count:678
no
Evaluation Count:0
0-678
612 prepareRequest(messagePair);
executed: prepareRequest(messagePair);
Execution Count:678
678
613 channels[i].request = messagePair.first;
executed (the execution status of this line is deduced): channels[i].request = messagePair.first;
-
614 channels[i].reply = messagePair.second;
executed (the execution status of this line is deduced): channels[i].reply = messagePair.second;
-
615 return true;
executed: return true;
Execution Count:678
678
616 } -
617 return false;
executed: return false;
Execution Count:34
34
618} -
619 -
620QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest() -
621{ -
622 if (!highPriorityQueue.isEmpty())
partially evaluated: !highPriorityQueue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
623 return highPriorityQueue.last().first;
never executed: return highPriorityQueue.last().first;
0
624 if (!lowPriorityQueue.isEmpty())
partially evaluated: !lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
625 return lowPriorityQueue.last().first;
executed: return lowPriorityQueue.last().first;
Execution Count:15
15
626 return QHttpNetworkRequest();
never executed: return QHttpNetworkRequest();
0
627} -
628 -
629// this is called from _q_startNextRequest and when a request has been sent down a socket from the channel -
630void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) -
631{ -
632 // return fast if there is nothing to pipeline -
633 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
partially evaluated: highPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:1175
no
Evaluation Count:0
evaluated: lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1164
0-1175
634 return;
executed: return;
Execution Count:11
11
635 -
636 int i = indexOf(socket);
executed (the execution status of this line is deduced): int i = indexOf(socket);
-
637 -
638 // return fast if there was no reply right now processed -
639 if (channels[i].reply == 0)
partially evaluated: channels[i].reply == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1164
0-1164
640 return;
never executed: return;
0
641 -
642 if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) {
evaluated: ! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:1150
14-1150
643 return;
executed: return;
Execution Count:14
14
644 } -
645 -
646 if (channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported)
evaluated: channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported
TRUEFALSE
yes
Evaluation Count:355
yes
Evaluation Count:795
355-795
647 return;
executed: return;
Execution Count:355
355
648 -
649 // the current request that is in must already support pipelining -
650 if (!channels[i].request.isPipeliningAllowed())
evaluated: !channels[i].request.isPipeliningAllowed()
TRUEFALSE
yes
Evaluation Count:791
yes
Evaluation Count:4
4-791
651 return;
executed: return;
Execution Count:791
791
652 -
653 // the current request must be a idempotent (right now we only check GET) -
654 if (channels[i].request.operation() != QHttpNetworkRequest::Get)
partially evaluated: channels[i].request.operation() != QHttpNetworkRequest::Get
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
655 return;
never executed: return;
0
656 -
657 // check if socket is connected -
658 if (socket->state() != QAbstractSocket::ConnectedState)
partially evaluated: socket->state() != QAbstractSocket::ConnectedState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
659 return;
never executed: return;
0
660 -
661 // check for resendCurrent -
662 if (channels[i].resendCurrent)
partially evaluated: channels[i].resendCurrent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
663 return;
never executed: return;
0
664 -
665 // we do not like authentication stuff -
666 // ### make sure to be OK with this in later releases -
667 if (!channels[i].authenticator.isNull()
partially evaluated: !channels[i].authenticator.isNull()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
668 && (!channels[i].authenticator.user().isEmpty()
partially evaluated: !channels[i].authenticator.user().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
669 || !channels[i].authenticator.password().isEmpty()))
partially evaluated: !channels[i].authenticator.password().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
670 return;
never executed: return;
0
671 if (!channels[i].proxyAuthenticator.isNull()
partially evaluated: !channels[i].proxyAuthenticator.isNull()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
672 && (!channels[i].proxyAuthenticator.user().isEmpty()
partially evaluated: !channels[i].proxyAuthenticator.user().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
673 || !channels[i].proxyAuthenticator.password().isEmpty()))
partially evaluated: !channels[i].proxyAuthenticator.password().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
674 return;
never executed: return;
0
675 -
676 // must be in ReadingState or WaitingState -
677 if (! (channels[i].state == QHttpNetworkConnectionChannel::WaitingState
partially evaluated: channels[i].state == QHttpNetworkConnectionChannel::WaitingState
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
678 || channels[i].state == QHttpNetworkConnectionChannel::ReadingState))
never evaluated: channels[i].state == QHttpNetworkConnectionChannel::ReadingState
0
679 return;
never executed: return;
0
680 -
681 int lengthBefore;
executed (the execution status of this line is deduced): int lengthBefore;
-
682 while (!highPriorityQueue.isEmpty()) {
partially evaluated: !highPriorityQueue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
683 lengthBefore = channels[i].alreadyPipelinedRequests.length();
never executed (the execution status of this line is deduced): lengthBefore = channels[i].alreadyPipelinedRequests.length();
-
684 fillPipeline(highPriorityQueue, channels[i]);
never executed (the execution status of this line is deduced): fillPipeline(highPriorityQueue, channels[i]);
-
685 -
686 if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {
never evaluated: channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength
0
687 channels[i].pipelineFlush();
never executed (the execution status of this line is deduced): channels[i].pipelineFlush();
-
688 return;
never executed: return;
0
689 } -
690 -
691 if (lengthBefore == channels[i].alreadyPipelinedRequests.length())
never evaluated: lengthBefore == channels[i].alreadyPipelinedRequests.length()
0
692 break; // did not process anything, now do the low prio queue
never executed: break;
0
693 }
never executed: }
0
694 -
695 while (!lowPriorityQueue.isEmpty()) {
evaluated: !lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
696 lengthBefore = channels[i].alreadyPipelinedRequests.length();
executed (the execution status of this line is deduced): lengthBefore = channels[i].alreadyPipelinedRequests.length();
-
697 fillPipeline(lowPriorityQueue, channels[i]);
executed (the execution status of this line is deduced): fillPipeline(lowPriorityQueue, channels[i]);
-
698 -
699 if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) {
evaluated: channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
700 channels[i].pipelineFlush();
executed (the execution status of this line is deduced): channels[i].pipelineFlush();
-
701 return;
executed: return;
Execution Count:3
3
702 } -
703 -
704 if (lengthBefore == channels[i].alreadyPipelinedRequests.length())
partially evaluated: lengthBefore == channels[i].alreadyPipelinedRequests.length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
705 break; // did not process anything
never executed: break;
0
706 }
executed: }
Execution Count:7
7
707 -
708 -
709 channels[i].pipelineFlush();
executed (the execution status of this line is deduced): channels[i].pipelineFlush();
-
710}
executed: }
Execution Count:1
1
711 -
712// returns true when the processing of a queue has been done -
713bool QHttpNetworkConnectionPrivate::fillPipeline(QList<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel) -
714{ -
715 if (queue.isEmpty())
partially evaluated: queue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
716 return true;
never executed: return true;
0
717 -
718 for (int i = queue.count() - 1; i >= 0; --i) {
partially evaluated: i >= 0
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
719 HttpMessagePair messagePair = queue.at(i);
executed (the execution status of this line is deduced): HttpMessagePair messagePair = queue.at(i);
-
720 const QHttpNetworkRequest &request = messagePair.first;
executed (the execution status of this line is deduced): const QHttpNetworkRequest &request = messagePair.first;
-
721 -
722 // we currently do not support pipelining if HTTP authentication is used -
723 if (!request.url().userInfo().isEmpty())
partially evaluated: !request.url().userInfo().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
724 continue;
never executed: continue;
0
725 -
726 // take only GET requests -
727 if (request.operation() != QHttpNetworkRequest::Get)
partially evaluated: request.operation() != QHttpNetworkRequest::Get
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
728 continue;
never executed: continue;
0
729 -
730 if (!request.isPipeliningAllowed())
partially evaluated: !request.isPipeliningAllowed()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
731 continue;
never executed: continue;
0
732 -
733 // remove it from the queue -
734 queue.takeAt(i);
executed (the execution status of this line is deduced): queue.takeAt(i);
-
735 // we modify the queue we iterate over here, but since we return from the function -
736 // afterwards this is fine. -
737 -
738 // actually send it -
739 if (!messagePair.second->d_func()->requestIsPrepared)
partially evaluated: !messagePair.second->d_func()->requestIsPrepared
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
740 prepareRequest(messagePair);
executed: prepareRequest(messagePair);
Execution Count:10
10
741 channel.pipelineInto(messagePair);
executed (the execution status of this line is deduced): channel.pipelineInto(messagePair);
-
742 -
743 // return false because we processed something and need to process again -
744 return false;
executed: return false;
Execution Count:10
10
745 } -
746 -
747 // return true, the queue has been processed and not changed -
748 return true;
never executed: return true;
0
749} -
750 -
751 -
752QString QHttpNetworkConnectionPrivate::errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket, const QString &extraDetail) -
753{ -
754 QString errorString;
executed (the execution status of this line is deduced): QString errorString;
-
755 switch (errorCode) { -
756 case QNetworkReply::HostNotFoundError: -
757 if (socket)
evaluated: socket
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
758 errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(socket->peerName());
executed: errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(socket->peerName());
Execution Count:2
2
759 else -
760 errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(hostName);
executed: errorString = QCoreApplication::translate("QHttp", "Host %1 not found").arg(hostName);
Execution Count:1
1
761 break;
executed: break;
Execution Count:3
3
762 case QNetworkReply::ConnectionRefusedError: -
763 errorString = QCoreApplication::translate("QHttp", "Connection refused");
never executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Connection refused");
-
764 break;
never executed: break;
0
765 case QNetworkReply::RemoteHostClosedError: -
766 errorString = QCoreApplication::translate("QHttp", "Connection closed");
executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Connection closed");
-
767 break;
executed: break;
Execution Count:50
50
768 case QNetworkReply::TimeoutError: -
769 errorString = QCoreApplication::translate("QAbstractSocket", "Socket operation timed out");
never executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QAbstractSocket", "Socket operation timed out");
-
770 break;
never executed: break;
0
771 case QNetworkReply::ProxyAuthenticationRequiredError: -
772 errorString = QCoreApplication::translate("QHttp", "Proxy requires authentication");
executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Proxy requires authentication");
-
773 break;
executed: break;
Execution Count:8
8
774 case QNetworkReply::AuthenticationRequiredError: -
775 errorString = QCoreApplication::translate("QHttp", "Host requires authentication");
executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Host requires authentication");
-
776 break;
executed: break;
Execution Count:30
30
777 case QNetworkReply::ProtocolFailure: -
778 errorString = QCoreApplication::translate("QHttp", "Data corrupted");
executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Data corrupted");
-
779 break;
executed: break;
Execution Count:1
1
780 case QNetworkReply::ProtocolUnknownError: -
781 errorString = QCoreApplication::translate("QHttp", "Unknown protocol specified");
never executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "Unknown protocol specified");
-
782 break;
never executed: break;
0
783 case QNetworkReply::SslHandshakeFailedError: -
784 errorString = QCoreApplication::translate("QHttp", "SSL handshake failed");
executed (the execution status of this line is deduced): errorString = QCoreApplication::translate("QHttp", "SSL handshake failed");
-
785 break;
executed: break;
Execution Count:10
10
786 default: -
787 // all other errors are treated as QNetworkReply::UnknownNetworkError -
788 errorString = extraDetail;
executed (the execution status of this line is deduced): errorString = extraDetail;
-
789 break;
executed: break;
Execution Count:3
3
790 } -
791 return errorString;
executed: return errorString;
Execution Count:105
105
792} -
793 -
794// this is called from the destructor of QHttpNetworkReply. It is called when -
795// the reply was finished correctly or when it was aborted. -
796void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) -
797{ -
798 Q_Q(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnection * const q = q_func();
-
799 -
800 // check if the reply is currently being processed or it is pipelined in -
801 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:3578
yes
Evaluation Count:589
589-3578
802 // is the reply associated the currently processing of this channel? -
803 if (channels[i].reply == reply) {
evaluated: channels[i].reply == reply
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:3549
29-3549
804 channels[i].reply = 0;
executed (the execution status of this line is deduced): channels[i].reply = 0;
-
805 channels[i].request = QHttpNetworkRequest();
executed (the execution status of this line is deduced): channels[i].request = QHttpNetworkRequest();
-
806 channels[i].resendCurrent = false;
executed (the execution status of this line is deduced): channels[i].resendCurrent = false;
-
807 -
808 if (!reply->isFinished() && !channels[i].alreadyPipelinedRequests.isEmpty()) {
partially evaluated: !reply->isFinished()
TRUEFALSE
yes
Evaluation Count:29
no
Evaluation Count:0
partially evaluated: !channels[i].alreadyPipelinedRequests.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
809 // the reply had to be prematurely removed, e.g. it was not finished -
810 // therefore we have to requeue the already pipelined requests. -
811 channels[i].requeueCurrentlyPipelinedRequests();
never executed (the execution status of this line is deduced): channels[i].requeueCurrentlyPipelinedRequests();
-
812 }
never executed: }
0
813 -
814 // if HTTP mandates we should close -
815 // or the reply is not finished yet, e.g. it was aborted -
816 // we have to close that connection -
817 if (reply->d_func()->isConnectionCloseEnabled() || !reply->isFinished())
evaluated: reply->d_func()->isConnectionCloseEnabled()
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:1
partially evaluated: !reply->isFinished()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-28
818 channels[i].close();
executed: channels[i].close();
Execution Count:29
29
819 -
820 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
821 return;
executed: return;
Execution Count:29
29
822 } -
823 -
824 // is the reply inside the pipeline of this channel already? -
825 for (int j = 0; j < channels[i].alreadyPipelinedRequests.length(); j++) {
evaluated: j < channels[i].alreadyPipelinedRequests.length()
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:3549
106-3549
826 if (channels[i].alreadyPipelinedRequests.at(j).second == reply) {
partially evaluated: channels[i].alreadyPipelinedRequests.at(j).second == reply
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:106
0-106
827 // Remove that HttpMessagePair -
828 channels[i].alreadyPipelinedRequests.removeAt(j);
never executed (the execution status of this line is deduced): channels[i].alreadyPipelinedRequests.removeAt(j);
-
829 -
830 channels[i].requeueCurrentlyPipelinedRequests();
never executed (the execution status of this line is deduced): channels[i].requeueCurrentlyPipelinedRequests();
-
831 -
832 // Since some requests had already been pipelined, but we removed -
833 // one and re-queued the others -
834 // we must force a connection close after the request that is -
835 // currently in processing has been finished. -
836 if (channels[i].reply)
never evaluated: channels[i].reply
0
837 channels[i].reply->d_func()->forceConnectionCloseEnabled = true;
never executed: channels[i].reply->d_func()->forceConnectionCloseEnabled = true;
0
838 -
839 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
840 return;
never executed: return;
0
841 } -
842 }
executed: }
Execution Count:106
106
843 }
executed: }
Execution Count:3549
3549
844 // remove from the high priority queue -
845 if (!highPriorityQueue.isEmpty()) {
partially evaluated: !highPriorityQueue.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:589
0-589
846 for (int j = highPriorityQueue.count() - 1; j >= 0; --j) {
never evaluated: j >= 0
0
847 HttpMessagePair messagePair = highPriorityQueue.at(j);
never executed (the execution status of this line is deduced): HttpMessagePair messagePair = highPriorityQueue.at(j);
-
848 if (messagePair.second == reply) {
never evaluated: messagePair.second == reply
0
849 highPriorityQueue.removeAt(j);
never executed (the execution status of this line is deduced): highPriorityQueue.removeAt(j);
-
850 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
851 return;
never executed: return;
0
852 } -
853 }
never executed: }
0
854 }
never executed: }
0
855 // remove from the low priority queue -
856 if (!lowPriorityQueue.isEmpty()) {
evaluated: !lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:526
63-526
857 for (int j = lowPriorityQueue.count() - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:1014
yes
Evaluation Count:57
57-1014
858 HttpMessagePair messagePair = lowPriorityQueue.at(j);
executed (the execution status of this line is deduced): HttpMessagePair messagePair = lowPriorityQueue.at(j);
-
859 if (messagePair.second == reply) {
evaluated: messagePair.second == reply
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1008
6-1008
860 lowPriorityQueue.removeAt(j);
executed (the execution status of this line is deduced): lowPriorityQueue.removeAt(j);
-
861 QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
-
862 return;
executed: return;
Execution Count:6
6
863 } -
864 }
executed: }
Execution Count:1008
1008
865 }
executed: }
Execution Count:57
57
866}
executed: }
Execution Count:583
583
867 -
868 -
869 -
870// This function must be called from the event loop. The only -
871// exception is documented in QHttpNetworkConnectionPrivate::queueRequest -
872// although it is called _q_startNextRequest, it will actually start multiple requests when possible -
873void QHttpNetworkConnectionPrivate::_q_startNextRequest() -
874{ -
875 // If there is no network layer state decided we should not start any new requests. -
876 if (networkLayerState == Unknown || networkLayerState == InProgress)
evaluated: networkLayerState == Unknown
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3142
partially evaluated: networkLayerState == InProgress
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3142
0-3142
877 return;
executed: return;
Execution Count:1
1
878 -
879 // If the QHttpNetworkConnection is currently paused then bail out immediately -
880 if (state == PausedState)
partially evaluated: state == PausedState
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3142
0-3142
881 return;
never executed: return;
0
882 -
883 //resend the necessary ones. -
884 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:18852
yes
Evaluation Count:3142
3142-18852
885 if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) {
evaluated: channels[i].resendCurrent
TRUEFALSE
yes
Evaluation Count:318
yes
Evaluation Count:18534
evaluated: (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:125
125-18534
886 channels[i].resendCurrent = false;
executed (the execution status of this line is deduced): channels[i].resendCurrent = false;
-
887 channels[i].state = QHttpNetworkConnectionChannel::IdleState;
executed (the execution status of this line is deduced): channels[i].state = QHttpNetworkConnectionChannel::IdleState;
-
888 -
889 // if this is not possible, error will be emitted and connection terminated -
890 if (!channels[i].resetUploadData())
partially evaluated: !channels[i].resetUploadData()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:193
0-193
891 continue;
never executed: continue;
0
892 channels[i].sendRequest();
executed (the execution status of this line is deduced): channels[i].sendRequest();
-
893 }
executed: }
Execution Count:193
193
894 }
executed: }
Execution Count:18852
18852
895 -
896 // dequeue new ones -
897 -
898 // return fast if there is nothing to do -
899 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
partially evaluated: highPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:3142
no
Evaluation Count:0
evaluated: lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:2318
yes
Evaluation Count:824
0-3142
900 return;
executed: return;
Execution Count:2318
2318
901 // try to get a free AND connected socket -
902 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:4944
yes
Evaluation Count:824
824-4944
903 if (channels[i].socket) {
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:1323
yes
Evaluation Count:3621
1323-3621
904 if (!channels[i].reply && !channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) {
evaluated: !channels[i].reply
TRUEFALSE
yes
Evaluation Count:207
yes
Evaluation Count:1116
evaluated: !channels[i].isSocketBusy()
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:46
evaluated: channels[i].socket->state() == QAbstractSocket::ConnectedState
TRUEFALSE
yes
Evaluation Count:130
yes
Evaluation Count:31
31-1116
905 if (dequeueRequest(channels[i].socket))
evaluated: dequeueRequest(channels[i].socket)
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:9
9-121
906 channels[i].sendRequest();
executed: channels[i].sendRequest();
Execution Count:121
121
907 }
executed: }
Execution Count:130
130
908 }
executed: }
Execution Count:1323
1323
909 }
executed: }
Execution Count:4944
4944
910 -
911 // try to push more into all sockets -
912 // ### FIXME we should move this to the beginning of the function -
913 // as soon as QtWebkit is properly using the pipelining -
914 // (e.g. not for XMLHttpRequest or the first page load) -
915 // ### FIXME we should also divide the requests more even -
916 // on the connected sockets -
917 //tryToFillPipeline(socket); -
918 // return fast if there is nothing to pipeline -
919 if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty())
partially evaluated: highPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:824
no
Evaluation Count:0
evaluated: lowPriorityQueue.isEmpty()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:761
0-824
920 return;
executed: return;
Execution Count:63
63
921 for (int i = 0; i < channelCount; i++)
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:4566
yes
Evaluation Count:761
761-4566
922 if (channels[i].socket && channels[i].socket->state() == QAbstractSocket::ConnectedState)
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:1246
yes
Evaluation Count:3320
evaluated: channels[i].socket->state() == QAbstractSocket::ConnectedState
TRUEFALSE
yes
Evaluation Count:1165
yes
Evaluation Count:81
81-3320
923 fillPipeline(channels[i].socket);
executed: fillPipeline(channels[i].socket);
Execution Count:1165
1165
924 -
925 // If there is not already any connected channels we need to connect a new one. -
926 // We do not pair the channel with the request until we know if it is -
927 // connected or not. This is to reuse connected channels before we connect new once. -
928 int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count();
executed (the execution status of this line is deduced): int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count();
-
929 for (int i = 0; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:1771
yes
Evaluation Count:191
191-1771
930 bool connectChannel = false;
executed (the execution status of this line is deduced): bool connectChannel = false;
-
931 if (channels[i].socket) {
evaluated: channels[i].socket
TRUEFALSE
yes
Evaluation Count:1241
yes
Evaluation Count:530
530-1241
932 if ((channels[i].socket->state() == QAbstractSocket::ConnectingState) || (channels[i].socket->state() == QAbstractSocket::HostLookupState))
evaluated: (channels[i].socket->state() == QAbstractSocket::ConnectingState)
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:1191
partially evaluated: (channels[i].socket->state() == QAbstractSocket::HostLookupState)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1191
0-1191
933 queuedRequest--;
executed: queuedRequest--;
Execution Count:50
50
934 if ( queuedRequest <=0 )
evaluated: queuedRequest <=0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1232
9-1232
935 break;
executed: break;
Execution Count:9
9
936 if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState))
evaluated: !channels[i].reply
TRUEFALSE
yes
Evaluation Count:69
yes
Evaluation Count:1163
evaluated: !channels[i].isSocketBusy()
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:38
partially evaluated: (channels[i].socket->state() == QAbstractSocket::UnconnectedState)
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-1163
937 connectChannel = true;
executed: connectChannel = true;
Execution Count:31
31
938 } else { // not previously used channel
executed: }
Execution Count:1232
1232
939 connectChannel = true;
executed (the execution status of this line is deduced): connectChannel = true;
-
940 }
executed: }
Execution Count:530
530
941 -
942 if (connectChannel) {
evaluated: connectChannel
TRUEFALSE
yes
Evaluation Count:561
yes
Evaluation Count:1201
561-1201
943 if (networkLayerState == IPv4)
evaluated: networkLayerState == IPv4
TRUEFALSE
yes
Evaluation Count:560
yes
Evaluation Count:1
1-560
944 channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol;
executed: channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol;
Execution Count:560
560
945 else if (networkLayerState == IPv6)
partially evaluated: networkLayerState == IPv6
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
946 channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol;
executed: channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol;
Execution Count:1
1
947 channels[i].ensureConnection();
executed (the execution status of this line is deduced): channels[i].ensureConnection();
-
948 queuedRequest--;
executed (the execution status of this line is deduced): queuedRequest--;
-
949 }
executed: }
Execution Count:561
561
950 -
951 if ( queuedRequest <=0 )
evaluated: queuedRequest <=0
TRUEFALSE
yes
Evaluation Count:561
yes
Evaluation Count:1201
561-1201
952 break;
executed: break;
Execution Count:561
561
953 }
executed: }
Execution Count:1201
1201
954}
executed: }
Execution Count:761
761
955 -
956 -
957void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply) -
958{ -
959 for (int i = 0 ; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:1223
yes
Evaluation Count:11
11-1223
960 if (channels[i].reply == reply) {
evaluated: channels[i].reply == reply
TRUEFALSE
yes
Evaluation Count:1157
yes
Evaluation Count:66
66-1157
961 // emulate a readyRead() from the socket -
962 QMetaObject::invokeMethod(&channels[i], "_q_readyRead", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(&channels[i], "_q_readyRead", Qt::QueuedConnection);
-
963 return;
executed: return;
Execution Count:1157
1157
964 } -
965 }
executed: }
Execution Count:66
66
966}
executed: }
Execution Count:11
11
967 -
968 -
969 -
970// The first time we start the connection is used we do not know if we -
971// should use IPv4 or IPv6. So we start a hostlookup to figure this out. -
972// Later when we do the connection the socket will not need to do another -
973// lookup as then the hostinfo will already be in the cache. -
974void QHttpNetworkConnectionPrivate::startHostInfoLookup() -
975{ -
976 networkLayerState = InProgress;
executed (the execution status of this line is deduced): networkLayerState = InProgress;
-
977 -
978 // check if we already now can decide if this is IPv4 or IPv6 -
979 QString lookupHost = hostName;
executed (the execution status of this line is deduced): QString lookupHost = hostName;
-
980#ifndef QT_NO_NETWORKPROXY -
981 if (networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability) {
evaluated: networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:461
46-461
982 lookupHost = networkProxy.hostName();
executed (the execution status of this line is deduced): lookupHost = networkProxy.hostName();
-
983 } else if (channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability) {
executed: }
Execution Count:46
evaluated: channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:412
46-412
984 lookupHost = channels[0].proxy.hostName();
executed (the execution status of this line is deduced): lookupHost = channels[0].proxy.hostName();
-
985 }
executed: }
Execution Count:49
49
986#endif -
987 QHostAddress temp;
executed (the execution status of this line is deduced): QHostAddress temp;
-
988 if (temp.setAddress(lookupHost)) {
evaluated: temp.setAddress(lookupHost)
TRUEFALSE
yes
Evaluation Count:99
yes
Evaluation Count:408
99-408
989 if (temp.protocol() == QAbstractSocket::IPv4Protocol) {
evaluated: temp.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:98
yes
Evaluation Count:1
1-98
990 networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
-
991 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
-
992 return;
executed: return;
Execution Count:98
98
993 } else if (temp.protocol() == QAbstractSocket::IPv6Protocol) {
partially evaluated: temp.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
994 networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
-
995 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
-
996 return;
executed: return;
Execution Count:1
1
997 } -
998 } else { -
999 int hostLookupId;
executed (the execution status of this line is deduced): int hostLookupId;
-
1000 bool immediateResultValid = false;
executed (the execution status of this line is deduced): bool immediateResultValid = false;
-
1001 QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost,
executed (the execution status of this line is deduced): QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost,
-
1002 this->q_func(),
executed (the execution status of this line is deduced): this->q_func(),
-
1003 SLOT(_q_hostLookupFinished(QHostInfo)),
executed (the execution status of this line is deduced): "1""_q_hostLookupFinished(QHostInfo)",
-
1004 &immediateResultValid,
executed (the execution status of this line is deduced): &immediateResultValid,
-
1005 &hostLookupId);
executed (the execution status of this line is deduced): &hostLookupId);
-
1006 if (immediateResultValid) {
evaluated: immediateResultValid
TRUEFALSE
yes
Evaluation Count:399
yes
Evaluation Count:9
9-399
1007 _q_hostLookupFinished(hostInfo);
executed (the execution status of this line is deduced): _q_hostLookupFinished(hostInfo);
-
1008 }
executed: }
Execution Count:399
399
1009 }
executed: }
Execution Count:408
408
1010} -
1011 -
1012 -
1013void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info) -
1014{ -
1015 bool bIpv4 = false;
executed (the execution status of this line is deduced): bool bIpv4 = false;
-
1016 bool bIpv6 = false;
executed (the execution status of this line is deduced): bool bIpv6 = false;
-
1017 bool foundAddress = false;
executed (the execution status of this line is deduced): bool foundAddress = false;
-
1018 -
1019 foreach (const QHostAddress &address, info.addresses()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(info.addresses())> _container_(info.addresses()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QHostAddress &address = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1020 if (address.protocol() == QAbstractSocket::IPv4Protocol) {
evaluated: address.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:407
yes
Evaluation Count:1
1-407
1021 if (!foundAddress) {
partially evaluated: !foundAddress
TRUEFALSE
yes
Evaluation Count:407
no
Evaluation Count:0
0-407
1022 foundAddress = true;
executed (the execution status of this line is deduced): foundAddress = true;
-
1023 delayIpv4 = false;
executed (the execution status of this line is deduced): delayIpv4 = false;
-
1024 }
executed: }
Execution Count:407
407
1025 bIpv4 = true;
executed (the execution status of this line is deduced): bIpv4 = true;
-
1026 } else if (address.protocol() == QAbstractSocket::IPv6Protocol) {
executed: }
Execution Count:407
partially evaluated: address.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-407
1027 if (!foundAddress) {
partially evaluated: !foundAddress
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1028 foundAddress = true;
never executed (the execution status of this line is deduced): foundAddress = true;
-
1029 delayIpv4 = true;
never executed (the execution status of this line is deduced): delayIpv4 = true;
-
1030 }
never executed: }
0
1031 bIpv6 = true;
executed (the execution status of this line is deduced): bIpv6 = true;
-
1032 }
executed: }
Execution Count:1
1
1033 } -
1034 -
1035 if (bIpv4 && bIpv6)
evaluated: bIpv4
TRUEFALSE
yes
Evaluation Count:407
yes
Evaluation Count:1
evaluated: bIpv6
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:406
1-407
1036 startNetworkLayerStateLookup();
executed: startNetworkLayerStateLookup();
Execution Count:1
1
1037 else if (bIpv4) {
evaluated: bIpv4
TRUEFALSE
yes
Evaluation Count:406
yes
Evaluation Count:1
1-406
1038 networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
-
1039 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
-
1040 } else if (bIpv6) {
executed: }
Execution Count:406
partially evaluated: bIpv6
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-406
1041 networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
never executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
-
1042 QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
-
1043 } else {
never executed: }
0
1044 if (dequeueRequest(channels[0].socket)) {
partially evaluated: dequeueRequest(channels[0].socket)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1045 emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError);
executed (the execution status of this line is deduced): emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError);
-
1046 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
-
1047 } else {
executed: }
Execution Count:1
1
1048 // Should not happen -
1049 qWarning() << "QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request";
never executed (the execution status of this line is deduced): QMessageLogger("access/qhttpnetworkconnection.cpp", 1049, __PRETTY_FUNCTION__).warning() << "QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request";
-
1050 networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
never executed (the execution status of this line is deduced): networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
-
1051 }
never executed: }
0
1052 } -
1053} -
1054 -
1055 -
1056// This will be used if the host lookup found both and Ipv4 and -
1057// Ipv6 address. Then we will start up two connections and pick -
1058// the network layer of the one that finish first. The second -
1059// connection will then be disconnected. -
1060void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() -
1061{ -
1062 if (channelCount > 1) {
partially evaluated: channelCount > 1
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1063 // At this time all channels should be unconnected. -
1064 Q_ASSERT(!channels[0].isSocketBusy());
executed (the execution status of this line is deduced): qt_noop();
-
1065 Q_ASSERT(!channels[1].isSocketBusy());
executed (the execution status of this line is deduced): qt_noop();
-
1066 -
1067 networkLayerState = InProgress;
executed (the execution status of this line is deduced): networkLayerState = InProgress;
-
1068 -
1069 channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol;
executed (the execution status of this line is deduced): channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol;
-
1070 channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol;
executed (the execution status of this line is deduced): channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol;
-
1071 -
1072 int timeout = 300;
executed (the execution status of this line is deduced): int timeout = 300;
-
1073#ifndef QT_NO_BEARERMANAGEMENT -
1074 if (networkSession) {
partially evaluated: networkSession
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1075 if (networkSession->configuration().bearerType() == QNetworkConfiguration::Bearer2G)
never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::Bearer2G
0
1076 timeout = 800;
never executed: timeout = 800;
0
1077 else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerCDMA2000)
never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerCDMA2000
0
1078 timeout = 500;
never executed: timeout = 500;
0
1079 else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerWCDMA)
never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerWCDMA
0
1080 timeout = 500;
never executed: timeout = 500;
0
1081 else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerHSPA)
never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerHSPA
0
1082 timeout = 400;
never executed: timeout = 400;
0
1083 } -
1084#endif -
1085 delayedConnectionTimer.start(timeout);
executed (the execution status of this line is deduced): delayedConnectionTimer.start(timeout);
-
1086 if (delayIpv4)
partially evaluated: delayIpv4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1087 channels[1].ensureConnection();
never executed: channels[1].ensureConnection();
0
1088 else -
1089 channels[0].ensureConnection();
executed: channels[0].ensureConnection();
Execution Count:1
1
1090 } else { -
1091 networkLayerState = InProgress;
never executed (the execution status of this line is deduced): networkLayerState = InProgress;
-
1092 channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol;
never executed (the execution status of this line is deduced): channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol;
-
1093 channels[0].ensureConnection();
never executed (the execution status of this line is deduced): channels[0].ensureConnection();
-
1094 }
never executed: }
0
1095} -
1096 -
1097void QHttpNetworkConnectionPrivate::networkLayerDetected(QAbstractSocket::NetworkLayerProtocol protocol) -
1098{ -
1099 for (int i = 0 ; i < channelCount; ++i) {
evaluated: i < channelCount
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
1100 if ((channels[i].networkLayerPreference != protocol) && (channels[i].state == QHttpNetworkConnectionChannel::ConnectingState)) {
evaluated: (channels[i].networkLayerPreference != protocol)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
partially evaluated: (channels[i].state == QHttpNetworkConnectionChannel::ConnectingState)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1101 channels[i].close();
never executed (the execution status of this line is deduced): channels[i].close();
-
1102 }
never executed: }
0
1103 }
executed: }
Execution Count:6
6
1104}
executed: }
Execution Count:1
1
1105 -
1106void QHttpNetworkConnectionPrivate::_q_connectDelayedChannel() -
1107{ -
1108 if (delayIpv4)
never evaluated: delayIpv4
0
1109 channels[0].ensureConnection();
never executed: channels[0].ensureConnection();
0
1110 else -
1111 channels[1].ensureConnection();
never executed: channels[1].ensureConnection();
0
1112} -
1113 -
1114#ifndef QT_NO_BEARERMANAGEMENT -
1115QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession) -
1116 : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent) -
1117{ -
1118 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1119 d->networkSession = networkSession;
executed (the execution status of this line is deduced): d->networkSession = networkSession;
-
1120 d->init();
executed (the execution status of this line is deduced): d->init();
-
1121}
executed: }
Execution Count:507
507
1122 -
1123QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession) -
1124 : QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt)), parent) -
1125{ -
1126 Q_D(QHttpNetworkConnection);
never executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1127 d->networkSession = networkSession;
never executed (the execution status of this line is deduced): d->networkSession = networkSession;
-
1128 d->init();
never executed (the execution status of this line is deduced): d->init();
-
1129}
never executed: }
0
1130#else -
1131QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent) -
1132 : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent) -
1133{ -
1134 Q_D(QHttpNetworkConnection); -
1135 d->init(); -
1136} -
1137 -
1138QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QObject *parent) -
1139 : QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt)), parent) -
1140{ -
1141 Q_D(QHttpNetworkConnection); -
1142 d->init(); -
1143} -
1144#endif -
1145 -
1146QHttpNetworkConnection::~QHttpNetworkConnection() -
1147{ -
1148} -
1149 -
1150QString QHttpNetworkConnection::hostName() const -
1151{ -
1152 Q_D(const QHttpNetworkConnection);
never executed (the execution status of this line is deduced): const QHttpNetworkConnectionPrivate * const d = d_func();
-
1153 return d->hostName;
never executed: return d->hostName;
0
1154} -
1155 -
1156quint16 QHttpNetworkConnection::port() const -
1157{ -
1158 Q_D(const QHttpNetworkConnection);
never executed (the execution status of this line is deduced): const QHttpNetworkConnectionPrivate * const d = d_func();
-
1159 return d->port;
never executed: return d->port;
0
1160} -
1161 -
1162QHttpNetworkReply* QHttpNetworkConnection::sendRequest(const QHttpNetworkRequest &request) -
1163{ -
1164 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1165 return d->queueRequest(request);
executed: return d->queueRequest(request);
Execution Count:694
694
1166} -
1167 -
1168bool QHttpNetworkConnection::isSsl() const -
1169{ -
1170 Q_D(const QHttpNetworkConnection);
never executed (the execution status of this line is deduced): const QHttpNetworkConnectionPrivate * const d = d_func();
-
1171 return d->encrypt;
never executed: return d->encrypt;
0
1172} -
1173 -
1174QHttpNetworkConnectionChannel *QHttpNetworkConnection::channels() const -
1175{ -
1176 return d_func()->channels;
never executed: return d_func()->channels;
0
1177} -
1178 -
1179#ifndef QT_NO_NETWORKPROXY -
1180void QHttpNetworkConnection::setCacheProxy(const QNetworkProxy &networkProxy) -
1181{ -
1182 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1183 d->networkProxy = networkProxy;
executed (the execution status of this line is deduced): d->networkProxy = networkProxy;
-
1184 // update the authenticator -
1185 if (!d->networkProxy.user().isEmpty()) {
partially evaluated: !d->networkProxy.user().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:507
0-507
1186 for (int i = 0; i < d->channelCount; ++i) {
never evaluated: i < d->channelCount
0
1187 d->channels[i].proxyAuthenticator.setUser(d->networkProxy.user());
never executed (the execution status of this line is deduced): d->channels[i].proxyAuthenticator.setUser(d->networkProxy.user());
-
1188 d->channels[i].proxyAuthenticator.setPassword(d->networkProxy.password());
never executed (the execution status of this line is deduced): d->channels[i].proxyAuthenticator.setPassword(d->networkProxy.password());
-
1189 }
never executed: }
0
1190 }
never executed: }
0
1191}
executed: }
Execution Count:507
507
1192 -
1193QNetworkProxy QHttpNetworkConnection::cacheProxy() const -
1194{ -
1195 Q_D(const QHttpNetworkConnection);
executed (the execution status of this line is deduced): const QHttpNetworkConnectionPrivate * const d = d_func();
-
1196 return d->networkProxy;
executed: return d->networkProxy;
Execution Count:467
467
1197} -
1198 -
1199void QHttpNetworkConnection::setTransparentProxy(const QNetworkProxy &networkProxy) -
1200{ -
1201 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1202 for (int i = 0; i < d->channelCount; ++i)
evaluated: i < d->channelCount
TRUEFALSE
yes
Evaluation Count:3042
yes
Evaluation Count:507
507-3042
1203 d->channels[i].setProxy(networkProxy);
executed: d->channels[i].setProxy(networkProxy);
Execution Count:3042
3042
1204}
executed: }
Execution Count:507
507
1205 -
1206QNetworkProxy QHttpNetworkConnection::transparentProxy() const -
1207{ -
1208 Q_D(const QHttpNetworkConnection);
executed (the execution status of this line is deduced): const QHttpNetworkConnectionPrivate * const d = d_func();
-
1209 return d->channels[0].proxy;
executed: return d->channels[0].proxy;
Execution Count:467
467
1210} -
1211#endif -
1212 -
1213 -
1214// SSL support below -
1215#ifndef QT_NO_SSL -
1216void QHttpNetworkConnection::setSslConfiguration(const QSslConfiguration &config) -
1217{ -
1218 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1219 if (!d->encrypt)
partially evaluated: !d->encrypt
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
1220 return;
never executed: return;
0
1221 -
1222 // set the config on all channels -
1223 for (int i = 0; i < d->channelCount; ++i)
evaluated: i < d->channelCount
TRUEFALSE
yes
Evaluation Count:258
yes
Evaluation Count:43
43-258
1224 d->channels[i].setSslConfiguration(config);
executed: d->channels[i].setSslConfiguration(config);
Execution Count:258
258
1225}
executed: }
Execution Count:43
43
1226 -
1227void QHttpNetworkConnection::ignoreSslErrors(int channel) -
1228{ -
1229 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1230 if (!d->encrypt)
partially evaluated: !d->encrypt
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
1231 return;
never executed: return;
0
1232 -
1233 if (channel == -1) { // ignore for all channels
partially evaluated: channel == -1
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
1234 for (int i = 0; i < d->channelCount; ++i) {
evaluated: i < d->channelCount
TRUEFALSE
yes
Evaluation Count:126
yes
Evaluation Count:21
21-126
1235 d->channels[i].ignoreSslErrors();
executed (the execution status of this line is deduced): d->channels[i].ignoreSslErrors();
-
1236 }
executed: }
Execution Count:126
126
1237 -
1238 } else {
executed: }
Execution Count:21
21
1239 d->channels[channel].ignoreSslErrors();
never executed (the execution status of this line is deduced): d->channels[channel].ignoreSslErrors();
-
1240 }
never executed: }
0
1241} -
1242 -
1243void QHttpNetworkConnection::ignoreSslErrors(const QList<QSslError> &errors, int channel) -
1244{ -
1245 Q_D(QHttpNetworkConnection);
executed (the execution status of this line is deduced): QHttpNetworkConnectionPrivate * const d = d_func();
-
1246 if (!d->encrypt)
partially evaluated: !d->encrypt
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1247 return;
never executed: return;
0
1248 -
1249 if (channel == -1) { // ignore for all channels
partially evaluated: channel == -1
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1250 for (int i = 0; i < d->channelCount; ++i) {
evaluated: i < d->channelCount
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:6
6-36
1251 d->channels[i].ignoreSslErrors(errors);
executed (the execution status of this line is deduced): d->channels[i].ignoreSslErrors(errors);
-
1252 }
executed: }
Execution Count:36
36
1253 -
1254 } else {
executed: }
Execution Count:6
6
1255 d->channels[channel].ignoreSslErrors(errors);
never executed (the execution status of this line is deduced): d->channels[channel].ignoreSslErrors(errors);
-
1256 }
never executed: }
0
1257} -
1258 -
1259#endif //QT_NO_SSL -
1260 -
1261#ifndef QT_NO_NETWORKPROXY -
1262// only called from QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired, not -
1263// from QHttpNetworkConnectionChannel::handleAuthenticationChallenge -
1264// e.g. it is for SOCKS proxies which require authentication. -
1265void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth) -
1266{ -
1267 // Also pause the connection because socket notifiers may fire while an user -
1268 // dialog is displaying -
1269 pauseConnection();
executed (the execution status of this line is deduced): pauseConnection();
-
1270 emit chan->reply->proxyAuthenticationRequired(proxy, auth);
executed (the execution status of this line is deduced): chan->reply->proxyAuthenticationRequired(proxy, auth);
-
1271 resumeConnection();
executed (the execution status of this line is deduced): resumeConnection();
-
1272 int i = indexOf(chan->socket);
executed (the execution status of this line is deduced): int i = indexOf(chan->socket);
-
1273 copyCredentials(i, auth, true);
executed (the execution status of this line is deduced): copyCredentials(i, auth, true);
-
1274}
executed: }
Execution Count:33
33
1275#endif -
1276 -
1277 -
1278QT_END_NAMESPACE -
1279 -
1280#include "moc_qhttpnetworkconnection_p.cpp" -
1281 -
1282#endif // QT_NO_HTTP -
1283 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial