Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | const int QHttpNetworkConnectionPrivate::defaultChannelCount = 6; | - |
13 | | - |
14 | | - |
15 | const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3; | - |
16 | | - |
17 | | - |
18 | const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2; | - |
19 | | - |
20 | | - |
21 | QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt) | - |
22 | : state(RunningState), | - |
23 | networkLayerState(Unknown), | - |
24 | hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true), | - |
25 | channelCount(defaultChannelCount) | - |
26 | | - |
27 | , networkProxy(QNetworkProxy::NoProxy) | - |
28 | | - |
29 | { | - |
30 | channels = new QHttpNetworkConnectionChannel[channelCount]; | - |
31 | } executed: } Execution Count:507 | 507 |
32 | | - |
33 | QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, quint16 port, bool encrypt) | - |
34 | : state(RunningState), networkLayerState(Unknown), | - |
35 | hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true), | - |
36 | channelCount(channelCount) | - |
37 | | - |
38 | , networkProxy(QNetworkProxy::NoProxy) | - |
39 | | - |
40 | { | - |
41 | channels = new QHttpNetworkConnectionChannel[channelCount]; | - |
42 | } | 0 |
43 | | - |
44 | | - |
45 | | - |
46 | QHttpNetworkConnectionPrivate::~QHttpNetworkConnectionPrivate() | - |
47 | { | - |
48 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:3042 | yes Evaluation Count:507 |
| 507-3042 |
49 | if (channels[i].socket) { evaluated: channels[i].socket yes Evaluation Count:531 | yes Evaluation Count:2511 |
| 531-2511 |
50 | channels[i].socket->close(); | - |
51 | delete channels[i].socket; | - |
52 | } executed: } Execution Count:531 | 531 |
53 | } executed: } Execution Count:3042 | 3042 |
54 | delete []channels; | - |
55 | } executed: } Execution Count:507 | 507 |
56 | | - |
57 | void QHttpNetworkConnectionPrivate::init() | - |
58 | { | - |
59 | QHttpNetworkConnection * const q = q_func(); | - |
60 | for (int i = 0; i < channelCount; i++) { evaluated: i < channelCount yes Evaluation Count:3042 | yes Evaluation Count:507 |
| 507-3042 |
61 | channels[i].setConnection(this->q_func()); | - |
62 | channels[i].ssl = encrypt; | - |
63 | | - |
64 | | - |
65 | channels[i].networkSession = networkSession; | - |
66 | | - |
67 | } executed: } Execution Count:3042 | 3042 |
68 | | - |
69 | delayedConnectionTimer.setSingleShot(true); | - |
70 | QObject::connect(&delayedConnectionTimer, "2""timeout()", q, "1""_q_connectDelayedChannel()"); | - |
71 | } executed: } Execution Count:507 | 507 |
72 | | - |
73 | void QHttpNetworkConnectionPrivate::pauseConnection() | - |
74 | { | - |
75 | state = PausedState; | - |
76 | | - |
77 | | - |
78 | for (int i = 0; i < channelCount; i++) { evaluated: i < channelCount yes Evaluation Count:1380 | yes Evaluation Count:230 |
| 230-1380 |
79 | if (channels[i].socket) { evaluated: channels[i].socket yes Evaluation Count:253 | yes Evaluation Count:1127 |
| 253-1127 |
80 | | - |
81 | if (encrypt) evaluated: encrypt yes Evaluation Count:71 | yes Evaluation Count:182 |
| 71-182 |
82 | QSslSocketPrivate::pauseSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket)); executed: QSslSocketPrivate::pauseSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket)); Execution Count:71 | 71 |
83 | else | - |
84 | | - |
85 | QAbstractSocketPrivate::pauseSocketNotifiers(channels[i].socket); executed: QAbstractSocketPrivate::pauseSocketNotifiers(channels[i].socket); Execution Count:182 | 182 |
86 | } | - |
87 | } executed: } Execution Count:1380 | 1380 |
88 | } executed: } Execution Count:230 | 230 |
89 | | - |
90 | void QHttpNetworkConnectionPrivate::resumeConnection() | - |
91 | { | - |
92 | state = RunningState; | - |
93 | | - |
94 | for (int i = 0; i < channelCount; i++) { evaluated: i < channelCount yes Evaluation Count:1380 | yes Evaluation Count:230 |
| 230-1380 |
95 | if (channels[i].socket) { evaluated: channels[i].socket yes Evaluation Count:253 | yes Evaluation Count:1127 |
| 253-1127 |
96 | | - |
97 | if (encrypt) evaluated: encrypt yes Evaluation Count:71 | yes Evaluation Count:182 |
| 71-182 |
98 | QSslSocketPrivate::resumeSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket)); executed: QSslSocketPrivate::resumeSocketNotifiers(static_cast<QSslSocket*>(channels[i].socket)); Execution Count:71 | 71 |
99 | else | - |
100 | | - |
101 | QAbstractSocketPrivate::resumeSocketNotifiers(channels[i].socket); executed: QAbstractSocketPrivate::resumeSocketNotifiers(channels[i].socket); Execution Count:182 | 182 |
102 | | - |
103 | | - |
104 | if (channels[i].state == QHttpNetworkConnectionChannel::WritingState) partially evaluated: channels[i].state == QHttpNetworkConnectionChannel::WritingState no Evaluation Count:0 | yes Evaluation Count:253 |
| 0-253 |
105 | QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection); never executed: QMetaObject::invokeMethod(&channels[i], "_q_uploadDataReadyRead", Qt::QueuedConnection); | 0 |
106 | } executed: } Execution Count:253 | 253 |
107 | } executed: } Execution Count:1380 | 1380 |
108 | | - |
109 | | - |
110 | QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection); | - |
111 | } executed: } Execution Count:230 | 230 |
112 | | - |
113 | int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const | - |
114 | { | - |
115 | for (int i = 0; i < channelCount; ++i) partially evaluated: i < channelCount yes Evaluation Count:6476 | no Evaluation Count:0 |
| 0-6476 |
116 | if (channels[i].socket == socket) evaluated: channels[i].socket == socket yes Evaluation Count:3157 | yes Evaluation Count:3319 |
| 3157-3319 |
117 | return i; executed: return i; Execution Count:3157 | 3157 |
118 | | - |
119 | QMessageLogger("access/qhttpnetworkconnection.cpp", 178, __PRETTY_FUNCTION__).fatal("Called with unknown socket object."); | - |
120 | return 0; never executed: return 0; | 0 |
121 | } | - |
122 | | - |
123 | | - |
124 | | - |
125 | | - |
126 | | - |
127 | bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *socket) | - |
128 | { | - |
129 | QHttpNetworkConnection * const q = q_func(); | - |
130 | | - |
131 | bool emitError = true; | - |
132 | int i = indexOf(socket); | - |
133 | int otherSocket = (i == 0 ? 1 : 0); partially evaluated: i == 0 yes Evaluation Count:47 | no Evaluation Count:0 |
| 0-47 |
134 | | - |
135 | | - |
136 | if (delayedConnectionTimer.isActive()) { partially evaluated: delayedConnectionTimer.isActive() no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
137 | delayedConnectionTimer.stop(); | - |
138 | channels[otherSocket].ensureConnection(); | - |
139 | } | 0 |
140 | | - |
141 | if (channelCount == 1) { partially evaluated: channelCount == 1 no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
142 | if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) never evaluated: networkLayerState == QHttpNetworkConnectionPrivate::InProgress | 0 |
143 | networkLayerState = QHttpNetworkConnectionPrivate::Unknown; never executed: networkLayerState = QHttpNetworkConnectionPrivate::Unknown; | 0 |
144 | channels[0].close(); | - |
145 | emitError = true; | - |
146 | } else { | 0 |
147 | if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { partially evaluated: networkLayerState == QHttpNetworkConnectionPrivate::InProgress no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
148 | if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { never evaluated: channels[otherSocket].isSocketBusy() never evaluated: (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState) | 0 |
149 | | - |
150 | channels[i].close(); | - |
151 | emitError = false; | - |
152 | } | 0 |
153 | else { | - |
154 | | - |
155 | networkLayerState = QHttpNetworkConnectionPrivate::Unknown; | - |
156 | channels[i].close(); | - |
157 | emitError = true; | - |
158 | } | 0 |
159 | } else { | - |
160 | if (((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol)) partially evaluated: (networkLayerState == QHttpNetworkConnectionPrivate::IPv4) yes Evaluation Count:47 | no Evaluation Count:0 |
partially evaluated: (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol) no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
161 | || ((networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol))) { partially evaluated: (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) no Evaluation Count:0 | yes Evaluation Count:47 |
never evaluated: (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol) | 0-47 |
162 | | - |
163 | channels[i].close(); | - |
164 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
165 | emitError = false; | - |
166 | } | 0 |
167 | if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown) partially evaluated: networkLayerState == QHttpNetworkConnectionPrivate::Unknown no Evaluation Count:0 | yes Evaluation Count:47 |
| 0-47 |
168 | QMessageLogger("access/qhttpnetworkconnection.cpp", 227, __PRETTY_FUNCTION__).warning() << "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 |
169 | } executed: } Execution Count:47 | 47 |
170 | } | - |
171 | return emitError; executed: return emitError; Execution Count:47 | 47 |
172 | } | - |
173 | | - |
174 | | - |
175 | qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const | - |
176 | { | - |
177 | return reply.d_func()->responseData.byteAmount(); never executed: return reply.d_func()->responseData.byteAmount(); | 0 |
178 | } | - |
179 | | - |
180 | qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const | - |
181 | { | - |
182 | return reply.d_func()->responseData.sizeNextBlock(); never executed: return reply.d_func()->responseData.sizeNextBlock(); | 0 |
183 | } | - |
184 | | - |
185 | void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair) | - |
186 | { | - |
187 | QHttpNetworkRequest &request = messagePair.first; | - |
188 | QHttpNetworkReply *reply = messagePair.second; | - |
189 | | - |
190 | | - |
191 | QByteArray value; | - |
192 | | - |
193 | QNonContiguousByteDevice* uploadByteDevice = request.uploadByteDevice(); | - |
194 | if (uploadByteDevice) { evaluated: uploadByteDevice yes Evaluation Count:179 | yes Evaluation Count:509 |
| 179-509 |
195 | if (request.contentLength() != -1 && uploadByteDevice->size() != -1) { evaluated: request.contentLength() != -1 yes Evaluation Count:112 | yes Evaluation Count:67 |
evaluated: uploadByteDevice->size() != -1 yes Evaluation Count:111 | yes Evaluation Count:1 |
| 1-112 |
196 | | - |
197 | request.setContentLength(qMin(uploadByteDevice->size(), request.contentLength())); | - |
198 | } else if (request.contentLength() == -1 && uploadByteDevice->size() != -1) { executed: } Execution Count:111 evaluated: request.contentLength() == -1 yes Evaluation Count:67 | yes Evaluation Count:1 |
partially evaluated: uploadByteDevice->size() != -1 yes Evaluation Count:67 | no Evaluation Count:0 |
| 0-111 |
199 | | - |
200 | request.setContentLength(uploadByteDevice->size()); | - |
201 | } else if (request.contentLength() != -1 && uploadByteDevice->size() == -1) { executed: } Execution Count:67 partially evaluated: request.contentLength() != -1 yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: uploadByteDevice->size() == -1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-67 |
202 | | - |
203 | } else if (request.contentLength() == -1 && uploadByteDevice->size() == -1) { executed: } Execution Count:1 never evaluated: request.contentLength() == -1 never evaluated: uploadByteDevice->size() == -1 | 0-1 |
204 | QMessageLogger("access/qhttpnetworkconnection.cpp", 263, __PRETTY_FUNCTION__).fatal("QHttpNetworkConnectionPrivate: Neither content-length nor upload device size were given"); | - |
205 | } | 0 |
206 | } | - |
207 | | - |
208 | | - |
209 | if (networkProxy.type() == QNetworkProxy::HttpCachingProxy) { evaluated: networkProxy.type() == QNetworkProxy::HttpCachingProxy yes Evaluation Count:8 | yes Evaluation Count:680 |
| 8-680 |
210 | value = request.headerField("proxy-connection"); | - |
211 | if (value.isEmpty()) partially evaluated: value.isEmpty() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
212 | request.setHeaderField("Proxy-Connection", "Keep-Alive"); executed: request.setHeaderField("Proxy-Connection", "Keep-Alive"); Execution Count:8 | 8 |
213 | } else { executed: } Execution Count:8 | 8 |
214 | | - |
215 | value = request.headerField("connection"); | - |
216 | if (value.isEmpty()) partially evaluated: value.isEmpty() yes Evaluation Count:680 | no Evaluation Count:0 |
| 0-680 |
217 | request.setHeaderField("Connection", "Keep-Alive"); executed: request.setHeaderField("Connection", "Keep-Alive"); Execution Count:680 | 680 |
218 | | - |
219 | } executed: } Execution Count:680 | 680 |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | value = request.headerField("accept-encoding"); | - |
228 | if (value.isEmpty()) { partially evaluated: value.isEmpty() yes Evaluation Count:688 | no Evaluation Count:0 |
| 0-688 |
229 | | - |
230 | request.setHeaderField("Accept-Encoding", "gzip, deflate"); | - |
231 | request.d->autoDecompress = true; | - |
232 | | - |
233 | | - |
234 | | - |
235 | | - |
236 | } executed: } Execution Count:688 | 688 |
237 | | - |
238 | | - |
239 | | - |
240 | | - |
241 | | - |
242 | value = request.headerField("accept-language"); | - |
243 | if (value.isEmpty()) { partially evaluated: value.isEmpty() yes Evaluation Count:688 | no Evaluation Count:0 |
| 0-688 |
244 | QString systemLocale = QLocale::system().name().replace(QChar::fromLatin1('_'),QChar::fromLatin1('-')); | - |
245 | QString acceptLanguage; | - |
246 | if (systemLocale == QLatin1String("C")) partially evaluated: systemLocale == QLatin1String("C") no Evaluation Count:0 | yes Evaluation Count:688 |
| 0-688 |
247 | acceptLanguage = QString::fromLatin1("en,*"); never executed: acceptLanguage = QString::fromLatin1("en,*"); | 0 |
248 | else if (systemLocale.startsWith(QLatin1String("en-"))) partially evaluated: systemLocale.startsWith(QLatin1String("en-")) yes Evaluation Count:688 | no Evaluation Count:0 |
| 0-688 |
249 | acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale); executed: acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale); Execution Count:688 | 688 |
250 | else | - |
251 | acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale); never executed: acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale); | 0 |
252 | request.setHeaderField("Accept-Language", acceptLanguage.toLatin1()); | - |
253 | } executed: } Execution Count:688 | 688 |
254 | | - |
255 | | - |
256 | value = request.headerField("user-agent"); | - |
257 | if (value.isEmpty()) evaluated: value.isEmpty() yes Evaluation Count:684 | yes Evaluation Count:4 |
| 4-684 |
258 | request.setHeaderField("User-Agent", "Mozilla/5.0"); executed: request.setHeaderField("User-Agent", "Mozilla/5.0"); Execution Count:684 | 684 |
259 | | - |
260 | value = request.headerField("host"); | - |
261 | if (value.isEmpty()) { evaluated: value.isEmpty() yes Evaluation Count:687 | yes Evaluation Count:1 |
| 1-687 |
262 | QHostAddress add; | - |
263 | QByteArray host; | - |
264 | if (add.setAddress(hostName)) { evaluated: add.setAddress(hostName) yes Evaluation Count:30 | yes Evaluation Count:657 |
| 30-657 |
265 | if (add.protocol() == QAbstractSocket::IPv6Protocol) evaluated: add.protocol() == QAbstractSocket::IPv6Protocol yes Evaluation Count:1 | yes Evaluation Count:29 |
| 1-29 |
266 | host = "[" + hostName.toLatin1() + "]"; executed: host = "[" + hostName.toLatin1() + "]"; Execution Count:1 | 1 |
267 | else | - |
268 | host = hostName.toLatin1(); executed: host = hostName.toLatin1(); Execution Count:29 | 29 |
269 | | - |
270 | } else { | - |
271 | host = QUrl::toAce(hostName); | - |
272 | } executed: } Execution Count:657 | 657 |
273 | | - |
274 | int port = request.url().port(); | - |
275 | if (port != -1) { evaluated: port != -1 yes Evaluation Count:148 | yes Evaluation Count:539 |
| 148-539 |
276 | host += ':'; | - |
277 | host += QByteArray::number(port); | - |
278 | } executed: } Execution Count:148 | 148 |
279 | | - |
280 | request.setHeaderField("Host", host); | - |
281 | } executed: } Execution Count:687 | 687 |
282 | | - |
283 | reply->d_func()->requestIsPrepared = true; | - |
284 | } executed: } Execution Count:688 | 688 |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | void QHttpNetworkConnectionPrivate::emitReplyError(QAbstractSocket *socket, | - |
290 | QHttpNetworkReply *reply, | - |
291 | QNetworkReply::NetworkError errorCode) | - |
292 | { | - |
293 | QHttpNetworkConnection * const q = q_func(); | - |
294 | | - |
295 | int i = 0; | - |
296 | if (socket) evaluated: socket yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
297 | i = indexOf(socket); executed: i = indexOf(socket); Execution Count:4 | 4 |
298 | | - |
299 | if (reply) { partially evaluated: reply yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
300 | | - |
301 | reply->d_func()->errorString = errorDetail(errorCode, socket); | - |
302 | reply->finishedWithError(errorCode, reply->d_func()->errorString); | - |
303 | | - |
304 | reply->d_func()->eraseData(); | - |
305 | | - |
306 | | - |
307 | channels[i].close(); | - |
308 | channels[i].reply = 0; | - |
309 | channels[i].request = QHttpNetworkRequest(); | - |
310 | if (socket) evaluated: socket yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
311 | channels[i].requeueCurrentlyPipelinedRequests(); executed: channels[i].requeueCurrentlyPipelinedRequests(); Execution Count:4 | 4 |
312 | | - |
313 | | - |
314 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
315 | } executed: } Execution Count:5 | 5 |
316 | } executed: } Execution Count:5 | 5 |
317 | | - |
318 | void QHttpNetworkConnectionPrivate::copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy) | - |
319 | { | - |
320 | qt_noop(); | - |
321 | | - |
322 | | - |
323 | if (!isProxy && channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm) evaluated: !isProxy yes Evaluation Count:124 | yes Evaluation Count:59 |
partially evaluated: channels[fromChannel].authMethod == QAuthenticatorPrivate::Ntlm no Evaluation Count:0 | yes Evaluation Count:124 |
| 0-124 |
324 | return; | 0 |
325 | if (isProxy && channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm) evaluated: isProxy yes Evaluation Count:59 | yes Evaluation Count:124 |
partially evaluated: channels[fromChannel].proxyAuthMethod == QAuthenticatorPrivate::Ntlm no Evaluation Count:0 | yes Evaluation Count:59 |
| 0-124 |
326 | return; | 0 |
327 | | - |
328 | | - |
329 | | - |
330 | QAuthenticator* otherAuth = 0; | - |
331 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:1098 | yes Evaluation Count:183 |
| 183-1098 |
332 | if (i == fromChannel) evaluated: i == fromChannel yes Evaluation Count:183 | yes Evaluation Count:915 |
| 183-915 |
333 | continue; executed: continue; Execution Count:183 | 183 |
334 | if (isProxy) evaluated: isProxy yes Evaluation Count:295 | yes Evaluation Count:620 |
| 295-620 |
335 | otherAuth = &channels[i].proxyAuthenticator; executed: otherAuth = &channels[i].proxyAuthenticator; Execution Count:295 | 295 |
336 | else | - |
337 | otherAuth = &channels[i].authenticator; executed: otherAuth = &channels[i].authenticator; Execution Count:620 | 620 |
338 | | - |
339 | if (otherAuth->user().compare(auth->user())) evaluated: otherAuth->user().compare(auth->user()) yes Evaluation Count:700 | yes Evaluation Count:215 |
| 215-700 |
340 | otherAuth->setUser(auth->user()); executed: otherAuth->setUser(auth->user()); Execution Count:700 | 700 |
341 | if (otherAuth->password().compare(auth->password())) evaluated: otherAuth->password().compare(auth->password()) yes Evaluation Count:710 | yes Evaluation Count:205 |
| 205-710 |
342 | otherAuth->setPassword(auth->password()); executed: otherAuth->setPassword(auth->password()); Execution Count:710 | 710 |
343 | } executed: } Execution Count:915 | 915 |
344 | } executed: } Execution Count:183 | 183 |
345 | | - |
346 | | - |
347 | | - |
348 | bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket *socket, QHttpNetworkReply *reply, | - |
349 | bool isProxy, bool &resend) | - |
350 | { | - |
351 | qt_noop(); | - |
352 | qt_noop(); | - |
353 | | - |
354 | resend = false; | - |
355 | | - |
356 | QList<QPair<QByteArray, QByteArray> > fields = reply->header(); | - |
357 | | - |
358 | | - |
359 | QAuthenticatorPrivate::Method authMethod = reply->d_func()->authenticationMethod(isProxy); | - |
360 | if (authMethod != QAuthenticatorPrivate::None) { evaluated: authMethod != QAuthenticatorPrivate::None yes Evaluation Count:332 | yes Evaluation Count:3 |
| 3-332 |
361 | int i = indexOf(socket); | - |
362 | | - |
363 | QAuthenticator* auth = 0; | - |
364 | if (isProxy) { evaluated: isProxy yes Evaluation Count:57 | yes Evaluation Count:275 |
| 57-275 |
365 | auth = &channels[i].proxyAuthenticator; | - |
366 | channels[i].proxyAuthMethod = authMethod; | - |
367 | } else { executed: } Execution Count:57 | 57 |
368 | auth = &channels[i].authenticator; | - |
369 | channels[i].authMethod = authMethod; | - |
370 | } executed: } Execution Count:275 | 275 |
371 | | - |
372 | if (auth->isNull()) partially evaluated: auth->isNull() no Evaluation Count:0 | yes Evaluation Count:332 |
| 0-332 |
373 | auth->detach(); never executed: auth->detach(); | 0 |
374 | QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(*auth); | - |
375 | priv->parseHttpResponse(fields, isProxy); | - |
376 | | - |
377 | if (priv->phase == QAuthenticatorPrivate::Done) { evaluated: priv->phase == QAuthenticatorPrivate::Done yes Evaluation Count:163 | yes Evaluation Count:169 |
| 163-169 |
378 | pauseConnection(); | - |
379 | if (!isProxy) { evaluated: !isProxy yes Evaluation Count:134 | yes Evaluation Count:29 |
| 29-134 |
380 | if (channels[i].authenticationCredentialsSent) { evaluated: channels[i].authenticationCredentialsSent yes Evaluation Count:46 | yes Evaluation Count:88 |
| 46-88 |
381 | auth->detach(); | - |
382 | priv = QAuthenticatorPrivate::getPrivate(*auth); | - |
383 | priv->hasFailed = true; | - |
384 | priv->phase = QAuthenticatorPrivate::Done; | - |
385 | channels[i].authenticationCredentialsSent = false; | - |
386 | } executed: } Execution Count:46 | 46 |
387 | reply->authenticationRequired(reply->request(), auth); | - |
388 | | - |
389 | } else { executed: } Execution Count:134 | 134 |
390 | if (channels[i].proxyCredentialsSent) { evaluated: channels[i].proxyCredentialsSent yes Evaluation Count:2 | yes Evaluation Count:27 |
| 2-27 |
391 | auth->detach(); | - |
392 | priv = QAuthenticatorPrivate::getPrivate(*auth); | - |
393 | priv->hasFailed = true; | - |
394 | priv->phase = QAuthenticatorPrivate::Done; | - |
395 | channels[i].proxyCredentialsSent = false; | - |
396 | } executed: } Execution Count:2 | 2 |
397 | reply->proxyAuthenticationRequired(networkProxy, auth); | - |
398 | | - |
399 | } executed: } Execution Count:29 | 29 |
400 | resumeConnection(); | - |
401 | | - |
402 | if (priv->phase != QAuthenticatorPrivate::Done) { evaluated: priv->phase != QAuthenticatorPrivate::Done yes Evaluation Count:132 | yes Evaluation Count:31 |
| 31-132 |
403 | | - |
404 | copyCredentials(i, auth, isProxy); | - |
405 | } executed: } Execution Count:132 | 132 |
406 | } else if (priv->phase == QAuthenticatorPrivate::Start) { partially evaluated: priv->phase == QAuthenticatorPrivate::Start yes Evaluation Count:169 | no Evaluation Count:0 |
executed: } Execution Count:163 | 0-169 |
407 | | - |
408 | | - |
409 | | - |
410 | reply->cacheCredentials(reply->request(), auth); | - |
411 | } executed: } Execution Count:169 | 169 |
412 | | - |
413 | | - |
414 | | - |
415 | | - |
416 | if (priv->phase == QAuthenticatorPrivate::Done || !reply->request().withCredentials()) { evaluated: priv->phase == QAuthenticatorPrivate::Done yes Evaluation Count:31 | yes Evaluation Count:301 |
partially evaluated: !reply->request().withCredentials() no Evaluation Count:0 | yes Evaluation Count:301 |
| 0-301 |
417 | | - |
418 | auth = 0; | - |
419 | if (isProxy) evaluated: isProxy yes Evaluation Count:3 | yes Evaluation Count:28 |
| 3-28 |
420 | channels[i].proxyAuthenticator = QAuthenticator(); executed: channels[i].proxyAuthenticator = QAuthenticator(); Execution Count:3 | 3 |
421 | else | - |
422 | channels[i].authenticator = QAuthenticator(); executed: channels[i].authenticator = QAuthenticator(); Execution Count:28 | 28 |
423 | | - |
424 | | - |
425 | channels[i].reply->headerChanged(); | - |
426 | channels[i].reply->readyRead(); | - |
427 | QNetworkReply::NetworkError errorCode = | - |
428 | isProxy evaluated: isProxy yes Evaluation Count:3 | yes Evaluation Count:28 |
| 3-28 |
429 | ? QNetworkReply::ProxyAuthenticationRequiredError | - |
430 | : QNetworkReply::AuthenticationRequiredError; | - |
431 | reply->d_func()->errorString = errorDetail(errorCode, socket); | - |
432 | reply->finishedWithError(errorCode, reply->d_func()->errorString); | - |
433 | | - |
434 | return true; executed: return true; Execution Count:31 | 31 |
435 | } | - |
436 | | - |
437 | resend = true; | - |
438 | return true; executed: return true; Execution Count:301 | 301 |
439 | } | - |
440 | return false; executed: return false; Execution Count:3 | 3 |
441 | } | - |
442 | | - |
443 | void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request) | - |
444 | { | - |
445 | qt_noop(); | - |
446 | | - |
447 | int i = indexOf(socket); | - |
448 | | - |
449 | | - |
450 | if (channels[i].authMethod != QAuthenticatorPrivate::None) { evaluated: channels[i].authMethod != QAuthenticatorPrivate::None yes Evaluation Count:157 | yes Evaluation Count:691 |
| 157-691 |
451 | if (!(channels[i].authMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 401)) { partially evaluated: channels[i].authMethod == QAuthenticatorPrivate::Ntlm no Evaluation Count:0 | yes Evaluation Count:157 |
never evaluated: channels[i].lastStatus != 401 | 0-157 |
452 | QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator); | - |
453 | if (priv && priv->method != QAuthenticatorPrivate::None) { partially evaluated: priv yes Evaluation Count:157 | no Evaluation Count:0 |
evaluated: priv->method != QAuthenticatorPrivate::None yes Evaluation Count:141 | yes Evaluation Count:16 |
| 0-157 |
454 | QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); | - |
455 | request.setHeaderField("Authorization", response); | - |
456 | channels[i].authenticationCredentialsSent = true; | - |
457 | } executed: } Execution Count:141 | 141 |
458 | } executed: } Execution Count:157 | 157 |
459 | } executed: } Execution Count:157 | 157 |
460 | | - |
461 | | - |
462 | if (channels[i].proxyAuthMethod != QAuthenticatorPrivate::None) { evaluated: channels[i].proxyAuthMethod != QAuthenticatorPrivate::None yes Evaluation Count:43 | yes Evaluation Count:805 |
| 43-805 |
463 | if (!(channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm && channels[i].lastStatus != 407)) { partially evaluated: channels[i].proxyAuthMethod == QAuthenticatorPrivate::Ntlm no Evaluation Count:0 | yes Evaluation Count:43 |
never evaluated: channels[i].lastStatus != 407 | 0-43 |
464 | QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator); | - |
465 | if (priv && priv->method != QAuthenticatorPrivate::None) { partially evaluated: priv yes Evaluation Count:43 | no Evaluation Count:0 |
evaluated: priv->method != QAuthenticatorPrivate::None yes Evaluation Count:41 | yes Evaluation Count:2 |
| 0-43 |
466 | QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); | - |
467 | request.setHeaderField("Proxy-Authorization", response); | - |
468 | channels[i].proxyCredentialsSent = true; | - |
469 | } executed: } Execution Count:41 | 41 |
470 | } executed: } Execution Count:43 | 43 |
471 | } executed: } Execution Count:43 | 43 |
472 | } executed: } Execution Count:848 | 848 |
473 | | - |
474 | QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetworkRequest &request) | - |
475 | { | - |
476 | QHttpNetworkConnection * const q = q_func(); | - |
477 | | - |
478 | | - |
479 | QHttpNetworkReply *reply = new QHttpNetworkReply(request.url()); | - |
480 | reply->setRequest(request); | - |
481 | reply->d_func()->connection = q; | - |
482 | reply->d_func()->connectionChannel = &channels[0]; | - |
483 | HttpMessagePair pair = qMakePair(request, reply); | - |
484 | | - |
485 | switch (request.priority()) { | - |
486 | case QHttpNetworkRequest::HighPriority: | - |
487 | highPriorityQueue.prepend(pair); | - |
488 | break; | 0 |
489 | case QHttpNetworkRequest::NormalPriority: | - |
490 | case QHttpNetworkRequest::LowPriority: | - |
491 | lowPriorityQueue.prepend(pair); | - |
492 | break; executed: break; Execution Count:694 | 694 |
493 | } | - |
494 | | - |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | if (networkLayerState == Unknown) { evaluated: networkLayerState == Unknown yes Evaluation Count:507 | yes Evaluation Count:187 |
| 187-507 |
500 | startHostInfoLookup(); | - |
501 | } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) { partially evaluated: networkLayerState == IPv4 yes Evaluation Count:187 | no Evaluation Count:0 |
never evaluated: networkLayerState == IPv6 executed: } Execution Count:507 | 0-507 |
502 | _q_startNextRequest(); | - |
503 | } executed: } Execution Count:187 | 187 |
504 | return reply; executed: return reply; Execution Count:694 | 694 |
505 | } | - |
506 | | - |
507 | void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair) | - |
508 | { | - |
509 | QHttpNetworkConnection * const q = q_func(); | - |
510 | | - |
511 | QHttpNetworkRequest request = pair.first; | - |
512 | switch (request.priority()) { | - |
513 | case QHttpNetworkRequest::HighPriority: | - |
514 | highPriorityQueue.prepend(pair); | - |
515 | break; | 0 |
516 | case QHttpNetworkRequest::NormalPriority: | - |
517 | case QHttpNetworkRequest::LowPriority: | - |
518 | lowPriorityQueue.prepend(pair); | - |
519 | break; | 0 |
520 | } | - |
521 | | - |
522 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
523 | } | 0 |
524 | | - |
525 | bool QHttpNetworkConnectionPrivate::dequeueRequest(QAbstractSocket *socket) | - |
526 | { | - |
527 | int i = 0; | - |
528 | if (socket) evaluated: socket yes Evaluation Count:711 | yes Evaluation Count:1 |
| 1-711 |
529 | i = indexOf(socket); executed: i = indexOf(socket); Execution Count:711 | 711 |
530 | | - |
531 | if (!highPriorityQueue.isEmpty()) { partially evaluated: !highPriorityQueue.isEmpty() no Evaluation Count:0 | yes Evaluation Count:712 |
| 0-712 |
532 | | - |
533 | HttpMessagePair messagePair = highPriorityQueue.takeLast(); | - |
534 | if (!messagePair.second->d_func()->requestIsPrepared) never evaluated: !messagePair.second->d_func()->requestIsPrepared | 0 |
535 | prepareRequest(messagePair); never executed: prepareRequest(messagePair); | 0 |
536 | channels[i].request = messagePair.first; | - |
537 | channels[i].reply = messagePair.second; | - |
538 | return true; never executed: return true; | 0 |
539 | } | - |
540 | | - |
541 | if (!lowPriorityQueue.isEmpty()) { evaluated: !lowPriorityQueue.isEmpty() yes Evaluation Count:678 | yes Evaluation Count:34 |
| 34-678 |
542 | | - |
543 | HttpMessagePair messagePair = lowPriorityQueue.takeLast(); | - |
544 | if (!messagePair.second->d_func()->requestIsPrepared) partially evaluated: !messagePair.second->d_func()->requestIsPrepared yes Evaluation Count:678 | no Evaluation Count:0 |
| 0-678 |
545 | prepareRequest(messagePair); executed: prepareRequest(messagePair); Execution Count:678 | 678 |
546 | channels[i].request = messagePair.first; | - |
547 | channels[i].reply = messagePair.second; | - |
548 | return true; executed: return true; Execution Count:678 | 678 |
549 | } | - |
550 | return false; executed: return false; Execution Count:34 | 34 |
551 | } | - |
552 | | - |
553 | QHttpNetworkRequest QHttpNetworkConnectionPrivate::predictNextRequest() | - |
554 | { | - |
555 | if (!highPriorityQueue.isEmpty()) partially evaluated: !highPriorityQueue.isEmpty() no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
556 | return highPriorityQueue.last().first; never executed: return highPriorityQueue.last().first; | 0 |
557 | if (!lowPriorityQueue.isEmpty()) partially evaluated: !lowPriorityQueue.isEmpty() yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
558 | return lowPriorityQueue.last().first; executed: return lowPriorityQueue.last().first; Execution Count:15 | 15 |
559 | return QHttpNetworkRequest(); never executed: return QHttpNetworkRequest(); | 0 |
560 | } | - |
561 | | - |
562 | | - |
563 | void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) | - |
564 | { | - |
565 | | - |
566 | if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) partially evaluated: highPriorityQueue.isEmpty() yes Evaluation Count:1175 | no Evaluation Count:0 |
evaluated: lowPriorityQueue.isEmpty() yes Evaluation Count:11 | yes Evaluation Count:1164 |
| 0-1175 |
567 | return; executed: return; Execution Count:11 | 11 |
568 | | - |
569 | int i = indexOf(socket); | - |
570 | | - |
571 | | - |
572 | if (channels[i].reply == 0) partially evaluated: channels[i].reply == 0 no Evaluation Count:0 | yes Evaluation Count:1164 |
| 0-1164 |
573 | return; | 0 |
574 | | - |
575 | if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) { evaluated: ! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength) yes Evaluation Count:14 | yes Evaluation Count:1150 |
| 14-1150 |
576 | return; executed: return; Execution Count:14 | 14 |
577 | } | - |
578 | | - |
579 | if (channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported) evaluated: channels[i].pipeliningSupported != QHttpNetworkConnectionChannel::PipeliningProbablySupported yes Evaluation Count:355 | yes Evaluation Count:795 |
| 355-795 |
580 | return; executed: return; Execution Count:355 | 355 |
581 | | - |
582 | | - |
583 | if (!channels[i].request.isPipeliningAllowed()) evaluated: !channels[i].request.isPipeliningAllowed() yes Evaluation Count:791 | yes Evaluation Count:4 |
| 4-791 |
584 | return; executed: return; Execution Count:791 | 791 |
585 | | - |
586 | | - |
587 | if (channels[i].request.operation() != QHttpNetworkRequest::Get) partially evaluated: channels[i].request.operation() != QHttpNetworkRequest::Get no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
588 | return; | 0 |
589 | | - |
590 | | - |
591 | if (socket->state() != QAbstractSocket::ConnectedState) partially evaluated: socket->state() != QAbstractSocket::ConnectedState no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
592 | return; | 0 |
593 | | - |
594 | | - |
595 | if (channels[i].resendCurrent) partially evaluated: channels[i].resendCurrent no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
596 | return; | 0 |
597 | | - |
598 | | - |
599 | | - |
600 | if (!channels[i].authenticator.isNull() partially evaluated: !channels[i].authenticator.isNull() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
601 | && (!channels[i].authenticator.user().isEmpty() partially evaluated: !channels[i].authenticator.user().isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
602 | || !channels[i].authenticator.password().isEmpty())) partially evaluated: !channels[i].authenticator.password().isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
603 | return; | 0 |
604 | if (!channels[i].proxyAuthenticator.isNull() partially evaluated: !channels[i].proxyAuthenticator.isNull() yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
605 | && (!channels[i].proxyAuthenticator.user().isEmpty() partially evaluated: !channels[i].proxyAuthenticator.user().isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
606 | || !channels[i].proxyAuthenticator.password().isEmpty())) partially evaluated: !channels[i].proxyAuthenticator.password().isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
607 | return; | 0 |
608 | | - |
609 | | - |
610 | if (! (channels[i].state == QHttpNetworkConnectionChannel::WaitingState partially evaluated: channels[i].state == QHttpNetworkConnectionChannel::WaitingState yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
611 | || channels[i].state == QHttpNetworkConnectionChannel::ReadingState)) never evaluated: channels[i].state == QHttpNetworkConnectionChannel::ReadingState | 0 |
612 | return; | 0 |
613 | | - |
614 | int lengthBefore; | - |
615 | while (!highPriorityQueue.isEmpty()) { partially evaluated: !highPriorityQueue.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
616 | lengthBefore = channels[i].alreadyPipelinedRequests.length(); | - |
617 | fillPipeline(highPriorityQueue, channels[i]); | - |
618 | | - |
619 | if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { never evaluated: channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength | 0 |
620 | channels[i].pipelineFlush(); | - |
621 | return; | 0 |
622 | } | - |
623 | | - |
624 | if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) never evaluated: lengthBefore == channels[i].alreadyPipelinedRequests.length() | 0 |
625 | break; | 0 |
626 | } | 0 |
627 | | - |
628 | while (!lowPriorityQueue.isEmpty()) { evaluated: !lowPriorityQueue.isEmpty() yes Evaluation Count:10 | yes Evaluation Count:1 |
| 1-10 |
629 | lengthBefore = channels[i].alreadyPipelinedRequests.length(); | - |
630 | fillPipeline(lowPriorityQueue, channels[i]); | - |
631 | | - |
632 | if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { evaluated: channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength yes Evaluation Count:3 | yes Evaluation Count:7 |
| 3-7 |
633 | channels[i].pipelineFlush(); | - |
634 | return; executed: return; Execution Count:3 | 3 |
635 | } | - |
636 | | - |
637 | if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) partially evaluated: lengthBefore == channels[i].alreadyPipelinedRequests.length() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
638 | break; | 0 |
639 | } executed: } Execution Count:7 | 7 |
640 | | - |
641 | | - |
642 | channels[i].pipelineFlush(); | - |
643 | } executed: } Execution Count:1 | 1 |
644 | | - |
645 | | - |
646 | bool QHttpNetworkConnectionPrivate::fillPipeline(QList<HttpMessagePair> &queue, QHttpNetworkConnectionChannel &channel) | - |
647 | { | - |
648 | if (queue.isEmpty()) partially evaluated: queue.isEmpty() no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
649 | return true; never executed: return true; | 0 |
650 | | - |
651 | for (int i = queue.count() - 1; i >= 0; --i) { partially evaluated: i >= 0 yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
652 | HttpMessagePair messagePair = queue.at(i); | - |
653 | const QHttpNetworkRequest &request = messagePair.first; | - |
654 | | - |
655 | | - |
656 | if (!request.url().userInfo().isEmpty()) partially evaluated: !request.url().userInfo().isEmpty() no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
657 | continue; never executed: continue; | 0 |
658 | | - |
659 | | - |
660 | if (request.operation() != QHttpNetworkRequest::Get) partially evaluated: request.operation() != QHttpNetworkRequest::Get no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
661 | continue; never executed: continue; | 0 |
662 | | - |
663 | if (!request.isPipeliningAllowed()) partially evaluated: !request.isPipeliningAllowed() no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
664 | continue; never executed: continue; | 0 |
665 | | - |
666 | | - |
667 | queue.takeAt(i); | - |
668 | | - |
669 | | - |
670 | | - |
671 | | - |
672 | if (!messagePair.second->d_func()->requestIsPrepared) partially evaluated: !messagePair.second->d_func()->requestIsPrepared yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
673 | prepareRequest(messagePair); executed: prepareRequest(messagePair); Execution Count:10 | 10 |
674 | channel.pipelineInto(messagePair); | - |
675 | | - |
676 | | - |
677 | return false; executed: return false; Execution Count:10 | 10 |
678 | } | - |
679 | | - |
680 | | - |
681 | return true; never executed: return true; | 0 |
682 | } | - |
683 | | - |
684 | | - |
685 | QString QHttpNetworkConnectionPrivate::errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket, const QString &extraDetail) | - |
686 | { | - |
687 | QString errorString; | - |
688 | switch (errorCode) { | - |
689 | case QNetworkReply::HostNotFoundError: | - |
690 | if (socket) evaluated: socket yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
691 | 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 |
692 | else | - |
693 | 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 |
694 | break; executed: break; Execution Count:3 | 3 |
695 | case QNetworkReply::ConnectionRefusedError: | - |
696 | errorString = QCoreApplication::translate("QHttp", "Connection refused"); | - |
697 | break; | 0 |
698 | case QNetworkReply::RemoteHostClosedError: | - |
699 | errorString = QCoreApplication::translate("QHttp", "Connection closed"); | - |
700 | break; executed: break; Execution Count:50 | 50 |
701 | case QNetworkReply::TimeoutError: | - |
702 | errorString = QCoreApplication::translate("QAbstractSocket", "Socket operation timed out"); | - |
703 | break; | 0 |
704 | case QNetworkReply::ProxyAuthenticationRequiredError: | - |
705 | errorString = QCoreApplication::translate("QHttp", "Proxy requires authentication"); | - |
706 | break; executed: break; Execution Count:8 | 8 |
707 | case QNetworkReply::AuthenticationRequiredError: | - |
708 | errorString = QCoreApplication::translate("QHttp", "Host requires authentication"); | - |
709 | break; executed: break; Execution Count:30 | 30 |
710 | case QNetworkReply::ProtocolFailure: | - |
711 | errorString = QCoreApplication::translate("QHttp", "Data corrupted"); | - |
712 | break; executed: break; Execution Count:1 | 1 |
713 | case QNetworkReply::ProtocolUnknownError: | - |
714 | errorString = QCoreApplication::translate("QHttp", "Unknown protocol specified"); | - |
715 | break; | 0 |
716 | case QNetworkReply::SslHandshakeFailedError: | - |
717 | errorString = QCoreApplication::translate("QHttp", "SSL handshake failed"); | - |
718 | break; executed: break; Execution Count:10 | 10 |
719 | default: | - |
720 | | - |
721 | errorString = extraDetail; | - |
722 | break; executed: break; Execution Count:3 | 3 |
723 | } | - |
724 | return errorString; executed: return errorString; Execution Count:105 | 105 |
725 | } | - |
726 | | - |
727 | | - |
728 | | - |
729 | void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) | - |
730 | { | - |
731 | QHttpNetworkConnection * const q = q_func(); | - |
732 | | - |
733 | | - |
734 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:3578 | yes Evaluation Count:589 |
| 589-3578 |
735 | | - |
736 | if (channels[i].reply == reply) { evaluated: channels[i].reply == reply yes Evaluation Count:29 | yes Evaluation Count:3549 |
| 29-3549 |
737 | channels[i].reply = 0; | - |
738 | channels[i].request = QHttpNetworkRequest(); | - |
739 | channels[i].resendCurrent = false; | - |
740 | | - |
741 | if (!reply->isFinished() && !channels[i].alreadyPipelinedRequests.isEmpty()) { partially evaluated: !reply->isFinished() yes Evaluation Count:29 | no Evaluation Count:0 |
partially evaluated: !channels[i].alreadyPipelinedRequests.isEmpty() no Evaluation Count:0 | yes Evaluation Count:29 |
| 0-29 |
742 | | - |
743 | | - |
744 | channels[i].requeueCurrentlyPipelinedRequests(); | - |
745 | } | 0 |
746 | | - |
747 | | - |
748 | | - |
749 | | - |
750 | if (reply->d_func()->isConnectionCloseEnabled() || !reply->isFinished()) evaluated: reply->d_func()->isConnectionCloseEnabled() yes Evaluation Count:28 | yes Evaluation Count:1 |
partially evaluated: !reply->isFinished() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-28 |
751 | channels[i].close(); executed: channels[i].close(); Execution Count:29 | 29 |
752 | | - |
753 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
754 | return; executed: return; Execution Count:29 | 29 |
755 | } | - |
756 | | - |
757 | | - |
758 | for (int j = 0; j < channels[i].alreadyPipelinedRequests.length(); j++) { evaluated: j < channels[i].alreadyPipelinedRequests.length() yes Evaluation Count:106 | yes Evaluation Count:3549 |
| 106-3549 |
759 | if (channels[i].alreadyPipelinedRequests.at(j).second == reply) { partially evaluated: channels[i].alreadyPipelinedRequests.at(j).second == reply no Evaluation Count:0 | yes Evaluation Count:106 |
| 0-106 |
760 | | - |
761 | channels[i].alreadyPipelinedRequests.removeAt(j); | - |
762 | | - |
763 | channels[i].requeueCurrentlyPipelinedRequests(); | - |
764 | | - |
765 | | - |
766 | | - |
767 | | - |
768 | | - |
769 | if (channels[i].reply) never evaluated: channels[i].reply | 0 |
770 | channels[i].reply->d_func()->forceConnectionCloseEnabled = true; never executed: channels[i].reply->d_func()->forceConnectionCloseEnabled = true; | 0 |
771 | | - |
772 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
773 | return; | 0 |
774 | } | - |
775 | } executed: } Execution Count:106 | 106 |
776 | } executed: } Execution Count:3549 | 3549 |
777 | | - |
778 | if (!highPriorityQueue.isEmpty()) { partially evaluated: !highPriorityQueue.isEmpty() no Evaluation Count:0 | yes Evaluation Count:589 |
| 0-589 |
779 | for (int j = highPriorityQueue.count() - 1; j >= 0; --j) { | 0 |
780 | HttpMessagePair messagePair = highPriorityQueue.at(j); | - |
781 | if (messagePair.second == reply) { never evaluated: messagePair.second == reply | 0 |
782 | highPriorityQueue.removeAt(j); | - |
783 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
784 | return; | 0 |
785 | } | - |
786 | } | 0 |
787 | } | 0 |
788 | | - |
789 | if (!lowPriorityQueue.isEmpty()) { evaluated: !lowPriorityQueue.isEmpty() yes Evaluation Count:63 | yes Evaluation Count:526 |
| 63-526 |
790 | for (int j = lowPriorityQueue.count() - 1; j >= 0; --j) { evaluated: j >= 0 yes Evaluation Count:1014 | yes Evaluation Count:57 |
| 57-1014 |
791 | HttpMessagePair messagePair = lowPriorityQueue.at(j); | - |
792 | if (messagePair.second == reply) { evaluated: messagePair.second == reply yes Evaluation Count:6 | yes Evaluation Count:1008 |
| 6-1008 |
793 | lowPriorityQueue.removeAt(j); | - |
794 | QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); | - |
795 | return; executed: return; Execution Count:6 | 6 |
796 | } | - |
797 | } executed: } Execution Count:1008 | 1008 |
798 | } executed: } Execution Count:57 | 57 |
799 | } executed: } Execution Count:583 | 583 |
800 | | - |
801 | | - |
802 | | - |
803 | | - |
804 | | - |
805 | | - |
806 | void QHttpNetworkConnectionPrivate::_q_startNextRequest() | - |
807 | { | - |
808 | | - |
809 | if (networkLayerState == Unknown || networkLayerState == InProgress) evaluated: networkLayerState == Unknown yes Evaluation Count:1 | yes Evaluation Count:3142 |
partially evaluated: networkLayerState == InProgress no Evaluation Count:0 | yes Evaluation Count:3142 |
| 0-3142 |
810 | return; executed: return; Execution Count:1 | 1 |
811 | | - |
812 | | - |
813 | if (state == PausedState) partially evaluated: state == PausedState no Evaluation Count:0 | yes Evaluation Count:3142 |
| 0-3142 |
814 | return; | 0 |
815 | | - |
816 | | - |
817 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:18852 | yes Evaluation Count:3142 |
| 3142-18852 |
818 | if (channels[i].resendCurrent && (channels[i].state != QHttpNetworkConnectionChannel::ClosingState)) { evaluated: channels[i].resendCurrent yes Evaluation Count:318 | yes Evaluation Count:18534 |
evaluated: (channels[i].state != QHttpNetworkConnectionChannel::ClosingState) yes Evaluation Count:193 | yes Evaluation Count:125 |
| 125-18534 |
819 | channels[i].resendCurrent = false; | - |
820 | channels[i].state = QHttpNetworkConnectionChannel::IdleState; | - |
821 | | - |
822 | | - |
823 | if (!channels[i].resetUploadData()) partially evaluated: !channels[i].resetUploadData() no Evaluation Count:0 | yes Evaluation Count:193 |
| 0-193 |
824 | continue; never executed: continue; | 0 |
825 | channels[i].sendRequest(); | - |
826 | } executed: } Execution Count:193 | 193 |
827 | } executed: } Execution Count:18852 | 18852 |
828 | | - |
829 | | - |
830 | | - |
831 | | - |
832 | if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) partially evaluated: highPriorityQueue.isEmpty() yes Evaluation Count:3142 | no Evaluation Count:0 |
evaluated: lowPriorityQueue.isEmpty() yes Evaluation Count:2318 | yes Evaluation Count:824 |
| 0-3142 |
833 | return; executed: return; Execution Count:2318 | 2318 |
834 | | - |
835 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:4944 | yes Evaluation Count:824 |
| 824-4944 |
836 | if (channels[i].socket) { evaluated: channels[i].socket yes Evaluation Count:1323 | yes Evaluation Count:3621 |
| 1323-3621 |
837 | if (!channels[i].reply && !channels[i].isSocketBusy() && channels[i].socket->state() == QAbstractSocket::ConnectedState) { evaluated: !channels[i].reply yes Evaluation Count:207 | yes Evaluation Count:1116 |
evaluated: !channels[i].isSocketBusy() yes Evaluation Count:161 | yes Evaluation Count:46 |
evaluated: channels[i].socket->state() == QAbstractSocket::ConnectedState yes Evaluation Count:130 | yes Evaluation Count:31 |
| 31-1116 |
838 | if (dequeueRequest(channels[i].socket)) evaluated: dequeueRequest(channels[i].socket) yes Evaluation Count:121 | yes Evaluation Count:9 |
| 9-121 |
839 | channels[i].sendRequest(); executed: channels[i].sendRequest(); Execution Count:121 | 121 |
840 | } executed: } Execution Count:130 | 130 |
841 | } executed: } Execution Count:1323 | 1323 |
842 | } executed: } Execution Count:4944 | 4944 |
843 | if (highPriorityQueue.isEmpty() && lowPriorityQueue.isEmpty()) partially evaluated: highPriorityQueue.isEmpty() yes Evaluation Count:824 | no Evaluation Count:0 |
evaluated: lowPriorityQueue.isEmpty() yes Evaluation Count:63 | yes Evaluation Count:761 |
| 0-824 |
844 | return; executed: return; Execution Count:63 | 63 |
845 | for (int i = 0; i < channelCount; i++) evaluated: i < channelCount yes Evaluation Count:4566 | yes Evaluation Count:761 |
| 761-4566 |
846 | if (channels[i].socket && channels[i].socket->state() == QAbstractSocket::ConnectedState) evaluated: channels[i].socket yes Evaluation Count:1246 | yes Evaluation Count:3320 |
evaluated: channels[i].socket->state() == QAbstractSocket::ConnectedState yes Evaluation Count:1165 | yes Evaluation Count:81 |
| 81-3320 |
847 | fillPipeline(channels[i].socket); executed: fillPipeline(channels[i].socket); Execution Count:1165 | 1165 |
848 | | - |
849 | | - |
850 | | - |
851 | | - |
852 | int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count(); | - |
853 | for (int i = 0; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:1771 | yes Evaluation Count:191 |
| 191-1771 |
854 | bool connectChannel = false; | - |
855 | if (channels[i].socket) { evaluated: channels[i].socket yes Evaluation Count:1241 | yes Evaluation Count:530 |
| 530-1241 |
856 | if ((channels[i].socket->state() == QAbstractSocket::ConnectingState) || (channels[i].socket->state() == QAbstractSocket::HostLookupState)) evaluated: (channels[i].socket->state() == QAbstractSocket::ConnectingState) yes Evaluation Count:50 | yes Evaluation Count:1191 |
partially evaluated: (channels[i].socket->state() == QAbstractSocket::HostLookupState) no Evaluation Count:0 | yes Evaluation Count:1191 |
| 0-1191 |
857 | queuedRequest--; executed: queuedRequest--; Execution Count:50 | 50 |
858 | if ( queuedRequest <=0 ) evaluated: queuedRequest <=0 yes Evaluation Count:9 | yes Evaluation Count:1232 |
| 9-1232 |
859 | break; executed: break; Execution Count:9 | 9 |
860 | if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState)) evaluated: !channels[i].reply yes Evaluation Count:69 | yes Evaluation Count:1163 |
evaluated: !channels[i].isSocketBusy() yes Evaluation Count:31 | yes Evaluation Count:38 |
partially evaluated: (channels[i].socket->state() == QAbstractSocket::UnconnectedState) yes Evaluation Count:31 | no Evaluation Count:0 |
| 0-1163 |
861 | connectChannel = true; executed: connectChannel = true; Execution Count:31 | 31 |
862 | } else { executed: } Execution Count:1232 | 1232 |
863 | connectChannel = true; | - |
864 | } executed: } Execution Count:530 | 530 |
865 | | - |
866 | if (connectChannel) { evaluated: connectChannel yes Evaluation Count:561 | yes Evaluation Count:1201 |
| 561-1201 |
867 | if (networkLayerState == IPv4) evaluated: networkLayerState == IPv4 yes Evaluation Count:560 | yes Evaluation Count:1 |
| 1-560 |
868 | channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol; executed: channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol; Execution Count:560 | 560 |
869 | else if (networkLayerState == IPv6) partially evaluated: networkLayerState == IPv6 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
870 | channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol; executed: channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol; Execution Count:1 | 1 |
871 | channels[i].ensureConnection(); | - |
872 | queuedRequest--; | - |
873 | } executed: } Execution Count:561 | 561 |
874 | | - |
875 | if ( queuedRequest <=0 ) evaluated: queuedRequest <=0 yes Evaluation Count:561 | yes Evaluation Count:1201 |
| 561-1201 |
876 | break; executed: break; Execution Count:561 | 561 |
877 | } executed: } Execution Count:1201 | 1201 |
878 | } executed: } Execution Count:761 | 761 |
879 | | - |
880 | | - |
881 | void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply) | - |
882 | { | - |
883 | for (int i = 0 ; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:1223 | yes Evaluation Count:11 |
| 11-1223 |
884 | if (channels[i].reply == reply) { evaluated: channels[i].reply == reply yes Evaluation Count:1157 | yes Evaluation Count:66 |
| 66-1157 |
885 | | - |
886 | QMetaObject::invokeMethod(&channels[i], "_q_readyRead", Qt::QueuedConnection); | - |
887 | return; executed: return; Execution Count:1157 | 1157 |
888 | } | - |
889 | } executed: } Execution Count:66 | 66 |
890 | } executed: } Execution Count:11 | 11 |
891 | | - |
892 | | - |
893 | | - |
894 | | - |
895 | | - |
896 | | - |
897 | | - |
898 | void QHttpNetworkConnectionPrivate::startHostInfoLookup() | - |
899 | { | - |
900 | networkLayerState = InProgress; | - |
901 | | - |
902 | | - |
903 | QString lookupHost = hostName; | - |
904 | | - |
905 | if (networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability) { evaluated: networkProxy.capabilities() & QNetworkProxy::HostNameLookupCapability yes Evaluation Count:46 | yes Evaluation Count:461 |
| 46-461 |
906 | lookupHost = networkProxy.hostName(); | - |
907 | } else if (channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability) { executed: } Execution Count:46 evaluated: channels[0].proxy.capabilities() & QNetworkProxy::HostNameLookupCapability yes Evaluation Count:49 | yes Evaluation Count:412 |
| 46-412 |
908 | lookupHost = channels[0].proxy.hostName(); | - |
909 | } executed: } Execution Count:49 | 49 |
910 | | - |
911 | QHostAddress temp; | - |
912 | if (temp.setAddress(lookupHost)) { evaluated: temp.setAddress(lookupHost) yes Evaluation Count:99 | yes Evaluation Count:408 |
| 99-408 |
913 | if (temp.protocol() == QAbstractSocket::IPv4Protocol) { evaluated: temp.protocol() == QAbstractSocket::IPv4Protocol yes Evaluation Count:98 | yes Evaluation Count:1 |
| 1-98 |
914 | networkLayerState = QHttpNetworkConnectionPrivate::IPv4; | - |
915 | QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection); | - |
916 | return; executed: return; Execution Count:98 | 98 |
917 | } else if (temp.protocol() == QAbstractSocket::IPv6Protocol) { partially evaluated: temp.protocol() == QAbstractSocket::IPv6Protocol yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
918 | networkLayerState = QHttpNetworkConnectionPrivate::IPv6; | - |
919 | QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection); | - |
920 | return; executed: return; Execution Count:1 | 1 |
921 | } | - |
922 | } else { | - |
923 | int hostLookupId; | - |
924 | bool immediateResultValid = false; | - |
925 | QHostInfo hostInfo = qt_qhostinfo_lookup(lookupHost, | - |
926 | this->q_func(), | - |
927 | "1""_q_hostLookupFinished(QHostInfo)", | - |
928 | &immediateResultValid, | - |
929 | &hostLookupId); | - |
930 | if (immediateResultValid) { evaluated: immediateResultValid yes Evaluation Count:399 | yes Evaluation Count:9 |
| 9-399 |
931 | _q_hostLookupFinished(hostInfo); | - |
932 | } executed: } Execution Count:399 | 399 |
933 | } executed: } Execution Count:408 | 408 |
934 | } | - |
935 | | - |
936 | | - |
937 | void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info) | - |
938 | { | - |
939 | bool bIpv4 = false; | - |
940 | bool bIpv6 = false; | - |
941 | bool foundAddress = false; | - |
942 | | - |
943 | 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;})) { | - |
944 | if (address.protocol() == QAbstractSocket::IPv4Protocol) { evaluated: address.protocol() == QAbstractSocket::IPv4Protocol yes Evaluation Count:407 | yes Evaluation Count:1 |
| 1-407 |
945 | if (!foundAddress) { partially evaluated: !foundAddress yes Evaluation Count:407 | no Evaluation Count:0 |
| 0-407 |
946 | foundAddress = true; | - |
947 | delayIpv4 = false; | - |
948 | } executed: } Execution Count:407 | 407 |
949 | bIpv4 = true; | - |
950 | } else if (address.protocol() == QAbstractSocket::IPv6Protocol) { executed: } Execution Count:407 partially evaluated: address.protocol() == QAbstractSocket::IPv6Protocol yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-407 |
951 | if (!foundAddress) { partially evaluated: !foundAddress no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
952 | foundAddress = true; | - |
953 | delayIpv4 = true; | - |
954 | } | 0 |
955 | bIpv6 = true; | - |
956 | } executed: } Execution Count:1 | 1 |
957 | } | - |
958 | | - |
959 | if (bIpv4 && bIpv6) evaluated: bIpv4 yes Evaluation Count:407 | yes Evaluation Count:1 |
evaluated: bIpv6 yes Evaluation Count:1 | yes Evaluation Count:406 |
| 1-407 |
960 | startNetworkLayerStateLookup(); executed: startNetworkLayerStateLookup(); Execution Count:1 | 1 |
961 | else if (bIpv4) { evaluated: bIpv4 yes Evaluation Count:406 | yes Evaluation Count:1 |
| 1-406 |
962 | networkLayerState = QHttpNetworkConnectionPrivate::IPv4; | - |
963 | QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection); | - |
964 | } else if (bIpv6) { executed: } Execution Count:406 partially evaluated: bIpv6 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-406 |
965 | networkLayerState = QHttpNetworkConnectionPrivate::IPv6; | - |
966 | QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection); | - |
967 | } else { | 0 |
968 | if (dequeueRequest(channels[0].socket)) { partially evaluated: dequeueRequest(channels[0].socket) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
969 | emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError); | - |
970 | networkLayerState = QHttpNetworkConnectionPrivate::Unknown; | - |
971 | } else { executed: } Execution Count:1 | 1 |
972 | | - |
973 | QMessageLogger("access/qhttpnetworkconnection.cpp", 1049, __PRETTY_FUNCTION__).warning() << "QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request"; | - |
974 | networkLayerState = QHttpNetworkConnectionPrivate::Unknown; | - |
975 | } | 0 |
976 | } | - |
977 | } | - |
978 | | - |
979 | | - |
980 | | - |
981 | | - |
982 | | - |
983 | | - |
984 | void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() | - |
985 | { | - |
986 | if (channelCount > 1) { partially evaluated: channelCount > 1 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
987 | | - |
988 | qt_noop(); | - |
989 | qt_noop(); | - |
990 | | - |
991 | networkLayerState = InProgress; | - |
992 | | - |
993 | channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; | - |
994 | channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; | - |
995 | | - |
996 | int timeout = 300; | - |
997 | | - |
998 | if (networkSession) { partially evaluated: networkSession no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
999 | if (networkSession->configuration().bearerType() == QNetworkConfiguration::Bearer2G) never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::Bearer2G | 0 |
1000 | timeout = 800; never executed: timeout = 800; | 0 |
1001 | else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerCDMA2000) never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerCDMA2000 | 0 |
1002 | timeout = 500; never executed: timeout = 500; | 0 |
1003 | else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerWCDMA) never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerWCDMA | 0 |
1004 | timeout = 500; never executed: timeout = 500; | 0 |
1005 | else if (networkSession->configuration().bearerType() == QNetworkConfiguration::BearerHSPA) never evaluated: networkSession->configuration().bearerType() == QNetworkConfiguration::BearerHSPA | 0 |
1006 | timeout = 400; never executed: timeout = 400; | 0 |
1007 | } | - |
1008 | | - |
1009 | delayedConnectionTimer.start(timeout); | - |
1010 | if (delayIpv4) partially evaluated: delayIpv4 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1011 | channels[1].ensureConnection(); never executed: channels[1].ensureConnection(); | 0 |
1012 | else | - |
1013 | channels[0].ensureConnection(); executed: channels[0].ensureConnection(); Execution Count:1 | 1 |
1014 | } else { | - |
1015 | networkLayerState = InProgress; | - |
1016 | channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol; | - |
1017 | channels[0].ensureConnection(); | - |
1018 | } | 0 |
1019 | } | - |
1020 | | - |
1021 | void QHttpNetworkConnectionPrivate::networkLayerDetected(QAbstractSocket::NetworkLayerProtocol protocol) | - |
1022 | { | - |
1023 | for (int i = 0 ; i < channelCount; ++i) { evaluated: i < channelCount yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
1024 | if ((channels[i].networkLayerPreference != protocol) && (channels[i].state == QHttpNetworkConnectionChannel::ConnectingState)) { evaluated: (channels[i].networkLayerPreference != protocol) yes Evaluation Count:5 | yes Evaluation Count:1 |
partially evaluated: (channels[i].state == QHttpNetworkConnectionChannel::ConnectingState) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1025 | channels[i].close(); | - |
1026 | } | 0 |
1027 | } executed: } Execution Count:6 | 6 |
1028 | } executed: } Execution Count:1 | 1 |
1029 | | - |
1030 | void QHttpNetworkConnectionPrivate::_q_connectDelayedChannel() | - |
1031 | { | - |
1032 | if (delayIpv4) never evaluated: delayIpv4 | 0 |
1033 | channels[0].ensureConnection(); never executed: channels[0].ensureConnection(); | 0 |
1034 | else | - |
1035 | channels[1].ensureConnection(); never executed: channels[1].ensureConnection(); | 0 |
1036 | } | - |
1037 | | - |
1038 | | - |
1039 | QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession) | - |
1040 | : QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent) | - |
1041 | { | - |
1042 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1043 | d->networkSession = networkSession; | - |
1044 | d->init(); | - |
1045 | } executed: } Execution Count:507 | 507 |
1046 | | - |
1047 | QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession) | - |
1048 | : QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt)), parent) | - |
1049 | { | - |
1050 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1051 | d->networkSession = networkSession; | - |
1052 | d->init(); | - |
1053 | } | 0 |
1054 | QHttpNetworkConnection::~QHttpNetworkConnection() | - |
1055 | { | - |
1056 | } | - |
1057 | | - |
1058 | QString QHttpNetworkConnection::hostName() const | - |
1059 | { | - |
1060 | const QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1061 | return d->hostName; never executed: return d->hostName; | 0 |
1062 | } | - |
1063 | | - |
1064 | quint16 QHttpNetworkConnection::port() const | - |
1065 | { | - |
1066 | const QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1067 | return d->port; never executed: return d->port; | 0 |
1068 | } | - |
1069 | | - |
1070 | QHttpNetworkReply* QHttpNetworkConnection::sendRequest(const QHttpNetworkRequest &request) | - |
1071 | { | - |
1072 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1073 | return d->queueRequest(request); executed: return d->queueRequest(request); Execution Count:694 | 694 |
1074 | } | - |
1075 | | - |
1076 | bool QHttpNetworkConnection::isSsl() const | - |
1077 | { | - |
1078 | const QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1079 | return d->encrypt; never executed: return d->encrypt; | 0 |
1080 | } | - |
1081 | | - |
1082 | QHttpNetworkConnectionChannel *QHttpNetworkConnection::channels() const | - |
1083 | { | - |
1084 | return d_func()->channels; never executed: return d_func()->channels; | 0 |
1085 | } | - |
1086 | | - |
1087 | | - |
1088 | void QHttpNetworkConnection::setCacheProxy(const QNetworkProxy &networkProxy) | - |
1089 | { | - |
1090 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1091 | d->networkProxy = networkProxy; | - |
1092 | | - |
1093 | if (!d->networkProxy.user().isEmpty()) { partially evaluated: !d->networkProxy.user().isEmpty() no Evaluation Count:0 | yes Evaluation Count:507 |
| 0-507 |
1094 | for (int i = 0; i < d->channelCount; ++i) { never evaluated: i < d->channelCount | 0 |
1095 | d->channels[i].proxyAuthenticator.setUser(d->networkProxy.user()); | - |
1096 | d->channels[i].proxyAuthenticator.setPassword(d->networkProxy.password()); | - |
1097 | } | 0 |
1098 | } | 0 |
1099 | } executed: } Execution Count:507 | 507 |
1100 | | - |
1101 | QNetworkProxy QHttpNetworkConnection::cacheProxy() const | - |
1102 | { | - |
1103 | const QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1104 | return d->networkProxy; executed: return d->networkProxy; Execution Count:467 | 467 |
1105 | } | - |
1106 | | - |
1107 | void QHttpNetworkConnection::setTransparentProxy(const QNetworkProxy &networkProxy) | - |
1108 | { | - |
1109 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1110 | for (int i = 0; i < d->channelCount; ++i) evaluated: i < d->channelCount yes Evaluation Count:3042 | yes Evaluation Count:507 |
| 507-3042 |
1111 | d->channels[i].setProxy(networkProxy); executed: d->channels[i].setProxy(networkProxy); Execution Count:3042 | 3042 |
1112 | } executed: } Execution Count:507 | 507 |
1113 | | - |
1114 | QNetworkProxy QHttpNetworkConnection::transparentProxy() const | - |
1115 | { | - |
1116 | const QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1117 | return d->channels[0].proxy; executed: return d->channels[0].proxy; Execution Count:467 | 467 |
1118 | } | - |
1119 | | - |
1120 | | - |
1121 | | - |
1122 | | - |
1123 | | - |
1124 | void QHttpNetworkConnection::setSslConfiguration(const QSslConfiguration &config) | - |
1125 | { | - |
1126 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1127 | if (!d->encrypt) partially evaluated: !d->encrypt no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
1128 | return; | 0 |
1129 | | - |
1130 | | - |
1131 | for (int i = 0; i < d->channelCount; ++i) evaluated: i < d->channelCount yes Evaluation Count:258 | yes Evaluation Count:43 |
| 43-258 |
1132 | d->channels[i].setSslConfiguration(config); executed: d->channels[i].setSslConfiguration(config); Execution Count:258 | 258 |
1133 | } executed: } Execution Count:43 | 43 |
1134 | | - |
1135 | void QHttpNetworkConnection::ignoreSslErrors(int channel) | - |
1136 | { | - |
1137 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1138 | if (!d->encrypt) partially evaluated: !d->encrypt no Evaluation Count:0 | yes Evaluation Count:21 |
| 0-21 |
1139 | return; | 0 |
1140 | | - |
1141 | if (channel == -1) { partially evaluated: channel == -1 yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
1142 | for (int i = 0; i < d->channelCount; ++i) { evaluated: i < d->channelCount yes Evaluation Count:126 | yes Evaluation Count:21 |
| 21-126 |
1143 | d->channels[i].ignoreSslErrors(); | - |
1144 | } executed: } Execution Count:126 | 126 |
1145 | | - |
1146 | } else { executed: } Execution Count:21 | 21 |
1147 | d->channels[channel].ignoreSslErrors(); | - |
1148 | } | 0 |
1149 | } | - |
1150 | | - |
1151 | void QHttpNetworkConnection::ignoreSslErrors(const QList<QSslError> &errors, int channel) | - |
1152 | { | - |
1153 | QHttpNetworkConnectionPrivate * const d = d_func(); | - |
1154 | if (!d->encrypt) partially evaluated: !d->encrypt no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
1155 | return; | 0 |
1156 | | - |
1157 | if (channel == -1) { partially evaluated: channel == -1 yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
1158 | for (int i = 0; i < d->channelCount; ++i) { evaluated: i < d->channelCount yes Evaluation Count:36 | yes Evaluation Count:6 |
| 6-36 |
1159 | d->channels[i].ignoreSslErrors(errors); | - |
1160 | } executed: } Execution Count:36 | 36 |
1161 | | - |
1162 | } else { executed: } Execution Count:6 | 6 |
1163 | d->channels[channel].ignoreSslErrors(errors); | - |
1164 | } | 0 |
1165 | } | - |
1166 | | - |
1167 | | - |
1168 | | - |
1169 | | - |
1170 | | - |
1171 | | - |
1172 | | - |
1173 | void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpNetworkConnectionChannel *chan, const QNetworkProxy &proxy, QAuthenticator* auth) | - |
1174 | { | - |
1175 | | - |
1176 | | - |
1177 | pauseConnection(); | - |
1178 | chan->reply->proxyAuthenticationRequired(proxy, auth); | - |
1179 | resumeConnection(); | - |
1180 | int i = indexOf(chan->socket); | - |
1181 | copyCredentials(i, auth, true); | - |
1182 | } executed: } Execution Count:33 | 33 |
1183 | | - |
1184 | | - |
1185 | | - |
1186 | | - |
1187 | | - |
1188 | | - |
| | |