Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url) | - |
9 | { | - |
10 | QNetworkReply::NetworkError code; | - |
11 | | - |
12 | switch (httpStatusCode) { | - |
13 | case 401: | - |
14 | code = QNetworkReply::AuthenticationRequiredError; | - |
15 | break; | 0 |
16 | | - |
17 | case 403: | - |
18 | code = QNetworkReply::ContentOperationNotPermittedError; | - |
19 | break; executed: break; Execution Count:1 | 1 |
20 | | - |
21 | case 404: | - |
22 | code = QNetworkReply::ContentNotFoundError; | - |
23 | break; executed: break; Execution Count:4 | 4 |
24 | | - |
25 | case 405: | - |
26 | code = QNetworkReply::ContentOperationNotPermittedError; | - |
27 | break; executed: break; Execution Count:1 | 1 |
28 | | - |
29 | case 407: | - |
30 | code = QNetworkReply::ProxyAuthenticationRequiredError; | - |
31 | break; | 0 |
32 | | - |
33 | case 418: | - |
34 | code = QNetworkReply::ProtocolInvalidOperationError; | - |
35 | break; | 0 |
36 | | - |
37 | | - |
38 | default: | - |
39 | if (httpStatusCode > 500) { evaluated: httpStatusCode > 500 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
40 | | - |
41 | code = QNetworkReply::ProtocolUnknownError; | - |
42 | } else if (httpStatusCode >= 400) { partially evaluated: httpStatusCode >= 400 yes Evaluation Count:1 | no Evaluation Count:0 |
executed: } Execution Count:1 | 0-1 |
43 | | - |
44 | code = QNetworkReply::UnknownContentError; | - |
45 | } else { executed: } Execution Count:1 | 1 |
46 | QMessageLogger("access/qhttpthreaddelegate.cpp", 96, __PRETTY_FUNCTION__).warning("QNetworkAccess: got HTTP status code %d which is not expected from url: \"%s\"", | - |
47 | httpStatusCode, QString(url.toString()).toLocal8Bit().constData()); | - |
48 | code = QNetworkReply::ProtocolFailure; | - |
49 | } | 0 |
50 | } | - |
51 | | - |
52 | return code; executed: return code; Execution Count:8 | 8 |
53 | } | - |
54 | | - |
55 | | - |
56 | static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy) | - |
57 | { | - |
58 | QString result; | - |
59 | QUrl copy = url; | - |
60 | bool isEncrypted = copy.scheme().toLower() == QLatin1String("https"); | - |
61 | copy.setPort(copy.port(isEncrypted ? 443 : 80)); | - |
62 | result = copy.toString(QUrl::RemoveUserInfo | QUrl::RemovePath | | - |
63 | QUrl::RemoveQuery | QUrl::RemoveFragment | QUrl::FullyEncoded); | - |
64 | | - |
65 | | - |
66 | if (proxy && proxy->type() != QNetworkProxy::NoProxy) { evaluated: proxy yes Evaluation Count:122 | yes Evaluation Count:572 |
partially evaluated: proxy->type() != QNetworkProxy::NoProxy yes Evaluation Count:122 | no Evaluation Count:0 |
| 0-572 |
67 | QUrl key; | - |
68 | | - |
69 | switch (proxy->type()) { | - |
70 | case QNetworkProxy::Socks5Proxy: | - |
71 | key.setScheme(QLatin1String("proxy-socks5")); | - |
72 | break; executed: break; Execution Count:50 | 50 |
73 | | - |
74 | case QNetworkProxy::HttpProxy: | - |
75 | case QNetworkProxy::HttpCachingProxy: | - |
76 | key.setScheme(QLatin1String("proxy-http")); | - |
77 | break; executed: break; Execution Count:72 | 72 |
78 | | - |
79 | default: | - |
80 | break; | 0 |
81 | } | - |
82 | | - |
83 | if (!key.scheme().isEmpty()) { partially evaluated: !key.scheme().isEmpty() yes Evaluation Count:122 | no Evaluation Count:0 |
| 0-122 |
84 | key.setUserName(proxy->user()); | - |
85 | key.setHost(proxy->hostName()); | - |
86 | key.setPort(proxy->port()); | - |
87 | key.setQuery(result); | - |
88 | result = key.toString(QUrl::FullyEncoded); | - |
89 | } executed: } Execution Count:122 | 122 |
90 | } executed: } Execution Count:122 | 122 |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | return "http-connection:" + result.toLatin1(); executed: return "http-connection:" + result.toLatin1(); Execution Count:694 | 694 |
96 | } | - |
97 | | - |
98 | class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection, | - |
99 | public QNetworkAccessCache::CacheableObject | - |
100 | { | - |
101 | | - |
102 | public: | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt, QSharedPointer<QNetworkSession> networkSession) | - |
108 | : QHttpNetworkConnection(hostName, port, encrypt, 0, networkSession) | - |
109 | | - |
110 | { | - |
111 | setExpires(true); | - |
112 | setShareable(true); | - |
113 | } executed: } Execution Count:507 | 507 |
114 | | - |
115 | virtual void dispose() | - |
116 | { | - |
117 | | - |
118 | | - |
119 | | - |
120 | delete this; | - |
121 | } executed: } Execution Count:507 | 507 |
122 | }; | - |
123 | | - |
124 | | - |
125 | QThreadStorage<QNetworkAccessCache *> QHttpThreadDelegate::connections; | - |
126 | | - |
127 | | - |
128 | QHttpThreadDelegate::~QHttpThreadDelegate() | - |
129 | { | - |
130 | | - |
131 | if (httpReply) { evaluated: httpReply yes Evaluation Count:13 | yes Evaluation Count:682 |
| 13-682 |
132 | delete httpReply; | - |
133 | } executed: } Execution Count:13 | 13 |
134 | | - |
135 | | - |
136 | | - |
137 | if (connections.hasLocalData() && !cacheKey.isEmpty()) { evaluated: connections.hasLocalData() yes Evaluation Count:619 | yes Evaluation Count:76 |
evaluated: !cacheKey.isEmpty() yes Evaluation Count:618 | yes Evaluation Count:1 |
| 1-619 |
138 | connections.localData()->releaseEntry(cacheKey); | - |
139 | } executed: } Execution Count:618 | 618 |
140 | } executed: } Execution Count:695 | 695 |
141 | | - |
142 | | - |
143 | QHttpThreadDelegate::QHttpThreadDelegate(QObject *parent) : | - |
144 | QObject(parent) | - |
145 | , ssl(false) | - |
146 | , downloadBufferMaximumSize(0) | - |
147 | , readBufferMaxSize(0) | - |
148 | , bytesEmitted(0) | - |
149 | , pendingDownloadData(0) | - |
150 | , pendingDownloadProgress(0) | - |
151 | , synchronous(false) | - |
152 | , incomingStatusCode(0) | - |
153 | , isPipeliningUsed(false) | - |
154 | , incomingContentLength(-1) | - |
155 | , incomingErrorCode(QNetworkReply::NoError) | - |
156 | , downloadBuffer(0) | - |
157 | , httpConnection(0) | - |
158 | , httpReply(0) | - |
159 | , synchronousRequestLoop(0) | - |
160 | { | - |
161 | } executed: } Execution Count:695 | 695 |
162 | | - |
163 | | - |
164 | void QHttpThreadDelegate::startRequestSynchronously() | - |
165 | { | - |
166 | | - |
167 | | - |
168 | | - |
169 | synchronous = true; | - |
170 | | - |
171 | QEventLoop synchronousRequestLoop; | - |
172 | this->synchronousRequestLoop = &synchronousRequestLoop; | - |
173 | | - |
174 | | - |
175 | QTimer::singleShot(30*1000, this, "1""abortRequest()"); | - |
176 | | - |
177 | QMetaObject::invokeMethod(this, "startRequest", Qt::QueuedConnection); | - |
178 | synchronousRequestLoop.exec(); | - |
179 | | - |
180 | connections.localData()->releaseEntry(cacheKey); | - |
181 | connections.setLocalData(0); | - |
182 | | - |
183 | | - |
184 | | - |
185 | | - |
186 | } executed: } Execution Count:76 | 76 |
187 | | - |
188 | | - |
189 | | - |
190 | void QHttpThreadDelegate::startRequest() | - |
191 | { | - |
192 | | - |
193 | | - |
194 | | - |
195 | | - |
196 | | - |
197 | if (!connections.hasLocalData()) { evaluated: !connections.hasLocalData() yes Evaluation Count:505 | yes Evaluation Count:189 |
| 189-505 |
198 | connections.setLocalData(new QNetworkAccessCache()); | - |
199 | } executed: } Execution Count:505 | 505 |
200 | | - |
201 | | - |
202 | QUrl urlCopy = httpRequest.url(); | - |
203 | urlCopy.setPort(urlCopy.port(ssl ? 443 : 80)); | - |
204 | | - |
205 | | - |
206 | if (transparentProxy.type() != QNetworkProxy::NoProxy) evaluated: transparentProxy.type() != QNetworkProxy::NoProxy yes Evaluation Count:65 | yes Evaluation Count:629 |
| 65-629 |
207 | cacheKey = makeCacheKey(urlCopy, &transparentProxy); executed: cacheKey = makeCacheKey(urlCopy, &transparentProxy); Execution Count:65 | 65 |
208 | else if (cacheProxy.type() != QNetworkProxy::NoProxy) evaluated: cacheProxy.type() != QNetworkProxy::NoProxy yes Evaluation Count:57 | yes Evaluation Count:572 |
| 57-572 |
209 | cacheKey = makeCacheKey(urlCopy, &cacheProxy); executed: cacheKey = makeCacheKey(urlCopy, &cacheProxy); Execution Count:57 | 57 |
210 | else | - |
211 | | - |
212 | cacheKey = makeCacheKey(urlCopy, 0); executed: cacheKey = makeCacheKey(urlCopy, 0); Execution Count:572 | 572 |
213 | | - |
214 | | - |
215 | | - |
216 | httpConnection = static_cast<QNetworkAccessCachedHttpConnection *>(connections.localData()->requestEntryNow(cacheKey)); | - |
217 | if (httpConnection == 0) { evaluated: httpConnection == 0 yes Evaluation Count:507 | yes Evaluation Count:187 |
| 187-507 |
218 | | - |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | httpConnection = new QNetworkAccessCachedHttpConnection(urlCopy.host(), urlCopy.port(), ssl, networkSession); | - |
224 | | - |
225 | | - |
226 | | - |
227 | if (ssl && incomingSslConfiguration != QSslConfiguration::defaultConfiguration()) { evaluated: ssl yes Evaluation Count:72 | yes Evaluation Count:435 |
evaluated: incomingSslConfiguration != QSslConfiguration::defaultConfiguration() yes Evaluation Count:43 | yes Evaluation Count:29 |
| 29-435 |
228 | httpConnection->setSslConfiguration(incomingSslConfiguration); | - |
229 | } executed: } Execution Count:43 | 43 |
230 | | - |
231 | | - |
232 | | - |
233 | httpConnection->setTransparentProxy(transparentProxy); | - |
234 | httpConnection->setCacheProxy(cacheProxy); | - |
235 | | - |
236 | | - |
237 | | - |
238 | connections.localData()->addEntry(cacheKey, httpConnection); | - |
239 | } executed: } Execution Count:507 | 507 |
240 | | - |
241 | | - |
242 | | - |
243 | httpReply = httpConnection->sendRequest(httpRequest); | - |
244 | httpReply->setParent(this); | - |
245 | | - |
246 | | - |
247 | if (synchronous) { evaluated: synchronous yes Evaluation Count:76 | yes Evaluation Count:618 |
| 76-618 |
248 | connect(httpReply,"2""headerChanged()", this, "1""synchronousHeaderChangedSlot()"); | - |
249 | connect(httpReply,"2""finished()", this, "1""synchronousFinishedSlot()"); | - |
250 | connect(httpReply,"2""finishedWithError(QNetworkReply::NetworkError,QString)", | - |
251 | this, "1""synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError,QString)"); | - |
252 | | - |
253 | connect(httpReply, "2""authenticationRequired(QHttpNetworkRequest,QAuthenticator*)", | - |
254 | this, "1""synchronousAuthenticationRequiredSlot(QHttpNetworkRequest,QAuthenticator*)"); | - |
255 | connect(httpReply, "2""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)", | - |
256 | this, "1""synchronousProxyAuthenticationRequiredSlot(QNetworkProxy,QAuthenticator*)"); | - |
257 | | - |
258 | | - |
259 | } else if (!synchronous) { executed: } Execution Count:76 partially evaluated: !synchronous yes Evaluation Count:618 | no Evaluation Count:0 |
| 0-618 |
260 | connect(httpReply,"2""headerChanged()", this, "1""headerChangedSlot()"); | - |
261 | connect(httpReply,"2""finished()", this, "1""finishedSlot()"); | - |
262 | connect(httpReply,"2""finishedWithError(QNetworkReply::NetworkError,QString)", | - |
263 | this, "1""finishedWithErrorSlot(QNetworkReply::NetworkError,QString)"); | - |
264 | | - |
265 | connect(httpReply,"2""readyRead()", this, "1""readyReadSlot()"); | - |
266 | connect(httpReply,"2""dataReadProgress(qint64,qint64)", this, "1""dataReadProgressSlot(qint64,qint64)"); | - |
267 | | - |
268 | connect(httpReply,"2""sslErrors(QList<QSslError>)", this, "1""sslErrorsSlot(QList<QSslError>)"); | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | connect(httpReply, "2""authenticationRequired(QHttpNetworkRequest,QAuthenticator*)", | - |
274 | this, "2""authenticationRequired(QHttpNetworkRequest,QAuthenticator*)"); | - |
275 | connect(httpReply, "2""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)", | - |
276 | this, "2""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)"); | - |
277 | } executed: } Execution Count:618 | 618 |
278 | | - |
279 | connect(httpReply, "2""cacheCredentials(QHttpNetworkRequest,QAuthenticator*)", | - |
280 | this, "1""cacheCredentialsSlot(QHttpNetworkRequest,QAuthenticator*)"); | - |
281 | } executed: } Execution Count:694 | 694 |
282 | | - |
283 | | - |
284 | void QHttpThreadDelegate::abortRequest() | - |
285 | { | - |
286 | | - |
287 | | - |
288 | | - |
289 | if (httpReply) { partially evaluated: httpReply yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
290 | delete httpReply; | - |
291 | httpReply = 0; | - |
292 | } executed: } Execution Count:2 | 2 |
293 | | - |
294 | | - |
295 | if (synchronous) { partially evaluated: synchronous no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
296 | incomingErrorCode = QNetworkReply::TimeoutError; | - |
297 | QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection); | - |
298 | } else { | 0 |
299 | | - |
300 | this->deleteLater(); | - |
301 | } executed: } Execution Count:2 | 2 |
302 | } | - |
303 | | - |
304 | void QHttpThreadDelegate::readBufferSizeChanged(qint64 size) | - |
305 | { | - |
306 | | - |
307 | | - |
308 | | - |
309 | if (httpReply) { partially evaluated: httpReply yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
310 | httpReply->setDownstreamLimited(size > 0); | - |
311 | httpReply->setReadBufferSize(size); | - |
312 | readBufferMaxSize = size; | - |
313 | } executed: } Execution Count:10 | 10 |
314 | } executed: } Execution Count:10 | 10 |
315 | | - |
316 | void QHttpThreadDelegate::readBufferFreed(qint64 size) | - |
317 | { | - |
318 | if (readBufferMaxSize) { partially evaluated: readBufferMaxSize yes Evaluation Count:881 | no Evaluation Count:0 |
| 0-881 |
319 | bytesEmitted -= size; | - |
320 | | - |
321 | QMetaObject::invokeMethod(this, "readyReadSlot", Qt::QueuedConnection); | - |
322 | } executed: } Execution Count:881 | 881 |
323 | } executed: } Execution Count:881 | 881 |
324 | | - |
325 | void QHttpThreadDelegate::readyReadSlot() | - |
326 | { | - |
327 | if (!httpReply) evaluated: !httpReply yes Evaluation Count:2 | yes Evaluation Count:12037 |
| 2-12037 |
328 | return; executed: return; Execution Count:2 | 2 |
329 | | - |
330 | | - |
331 | if (!downloadBuffer.isNull()) partially evaluated: !downloadBuffer.isNull() no Evaluation Count:0 | yes Evaluation Count:12037 |
| 0-12037 |
332 | return; | 0 |
333 | | - |
334 | if (readBufferMaxSize) { evaluated: readBufferMaxSize yes Evaluation Count:3122 | yes Evaluation Count:8915 |
| 3122-8915 |
335 | if (bytesEmitted < readBufferMaxSize) { evaluated: bytesEmitted < readBufferMaxSize yes Evaluation Count:3092 | yes Evaluation Count:30 |
| 30-3092 |
336 | qint64 sizeEmitted = 0; | - |
337 | while (httpReply->readAnyAvailable() && (sizeEmitted < (readBufferMaxSize-bytesEmitted))) { evaluated: httpReply->readAnyAvailable() yes Evaluation Count:2377 | yes Evaluation Count:2490 |
evaluated: (sizeEmitted < (readBufferMaxSize-bytesEmitted)) yes Evaluation Count:1775 | yes Evaluation Count:602 |
| 602-2490 |
338 | if (httpReply->sizeNextBlock() > (readBufferMaxSize-bytesEmitted)) { evaluated: httpReply->sizeNextBlock() > (readBufferMaxSize-bytesEmitted) yes Evaluation Count:595 | yes Evaluation Count:1180 |
| 595-1180 |
339 | sizeEmitted = readBufferMaxSize-bytesEmitted; | - |
340 | bytesEmitted += sizeEmitted; | - |
341 | pendingDownloadData->fetchAndAddRelease(1); | - |
342 | downloadData(httpReply->read(sizeEmitted)); | - |
343 | } else { executed: } Execution Count:595 | 595 |
344 | sizeEmitted = httpReply->sizeNextBlock(); | - |
345 | bytesEmitted += sizeEmitted; | - |
346 | pendingDownloadData->fetchAndAddRelease(1); | - |
347 | downloadData(httpReply->readAny()); | - |
348 | } executed: } Execution Count:1180 | 1180 |
349 | } | - |
350 | } else { executed: } Execution Count:3092 | 3092 |
351 | | - |
352 | } executed: } Execution Count:30 | 30 |
353 | | - |
354 | } else { | - |
355 | while (httpReply->readAnyAvailable()) { evaluated: httpReply->readAnyAvailable() yes Evaluation Count:4955 | yes Evaluation Count:8915 |
| 4955-8915 |
356 | pendingDownloadData->fetchAndAddRelease(1); | - |
357 | downloadData(httpReply->readAny()); | - |
358 | } executed: } Execution Count:4955 | 4955 |
359 | } executed: } Execution Count:8915 | 8915 |
360 | } | - |
361 | | - |
362 | void QHttpThreadDelegate::finishedSlot() | - |
363 | { | - |
364 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:535 |
| 0-535 |
365 | return; | 0 |
366 | | - |
367 | | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | while (httpReply->readAnyAvailable()) { evaluated: httpReply->readAnyAvailable() yes Evaluation Count:2 | yes Evaluation Count:535 |
| 2-535 |
373 | pendingDownloadData->fetchAndAddRelease(1); | - |
374 | downloadData(httpReply->readAny()); | - |
375 | } executed: } Execution Count:2 | 2 |
376 | | - |
377 | | - |
378 | if (ssl) evaluated: ssl yes Evaluation Count:48 | yes Evaluation Count:487 |
| 48-487 |
379 | sslConfigurationChanged(httpReply->sslConfiguration()); executed: sslConfigurationChanged(httpReply->sslConfiguration()); Execution Count:48 | 48 |
380 | | - |
381 | | - |
382 | if (httpReply->statusCode() >= 400) { evaluated: httpReply->statusCode() >= 400 yes Evaluation Count:8 | yes Evaluation Count:527 |
| 8-527 |
383 | | - |
384 | QString msg = QLatin1String("Error downloading %1 - server replied: %2"); | - |
385 | | - |
386 | msg = msg.arg(httpRequest.url().toString(), httpReply->reasonPhrase()); | - |
387 | error(statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()), msg); | - |
388 | } executed: } Execution Count:8 | 8 |
389 | | - |
390 | downloadFinished(); | - |
391 | | - |
392 | QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); | - |
393 | QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection); | - |
394 | httpReply = 0; | - |
395 | } executed: } Execution Count:535 | 535 |
396 | | - |
397 | void QHttpThreadDelegate::synchronousFinishedSlot() | - |
398 | { | - |
399 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:63 |
| 0-63 |
400 | return; | 0 |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | if (httpReply->statusCode() >= 400) { partially evaluated: httpReply->statusCode() >= 400 no Evaluation Count:0 | yes Evaluation Count:63 |
| 0-63 |
406 | | - |
407 | QString msg = QLatin1String("Error downloading %1 - server replied: %2"); | - |
408 | | - |
409 | incomingErrorDetail = msg.arg(httpRequest.url().toString(), httpReply->reasonPhrase()); | - |
410 | incomingErrorCode = statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()); | - |
411 | } | 0 |
412 | | - |
413 | synchronousDownloadData = httpReply->readAll(); | - |
414 | | - |
415 | QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); | - |
416 | QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection); | - |
417 | httpReply = 0; | - |
418 | } executed: } Execution Count:63 | 63 |
419 | | - |
420 | void QHttpThreadDelegate::finishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail) | - |
421 | { | - |
422 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:68 |
| 0-68 |
423 | return; | 0 |
424 | | - |
425 | | - |
426 | | - |
427 | | - |
428 | | - |
429 | | - |
430 | if (ssl) evaluated: ssl yes Evaluation Count:22 | yes Evaluation Count:46 |
| 22-46 |
431 | sslConfigurationChanged(httpReply->sslConfiguration()); executed: sslConfigurationChanged(httpReply->sslConfiguration()); Execution Count:22 | 22 |
432 | | - |
433 | error(errorCode,detail); | - |
434 | downloadFinished(); | - |
435 | | - |
436 | | - |
437 | QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); | - |
438 | QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection); | - |
439 | httpReply = 0; | - |
440 | } executed: } Execution Count:68 | 68 |
441 | | - |
442 | | - |
443 | void QHttpThreadDelegate::synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail) | - |
444 | { | - |
445 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
446 | return; | 0 |
447 | | - |
448 | | - |
449 | | - |
450 | | - |
451 | incomingErrorCode = errorCode; | - |
452 | incomingErrorDetail = detail; | - |
453 | | - |
454 | QMetaObject::invokeMethod(httpReply, "deleteLater", Qt::QueuedConnection); | - |
455 | QMetaObject::invokeMethod(synchronousRequestLoop, "quit", Qt::QueuedConnection); | - |
456 | httpReply = 0; | - |
457 | } executed: } Execution Count:13 | 13 |
458 | | - |
459 | static void downloadBufferDeleter(char *ptr) | - |
460 | { | - |
461 | delete[] ptr; | - |
462 | } executed: } Execution Count:334 | 334 |
463 | | - |
464 | void QHttpThreadDelegate::headerChangedSlot() | - |
465 | { | - |
466 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:564 |
| 0-564 |
467 | return; | 0 |
468 | | - |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | if (ssl) evaluated: ssl yes Evaluation Count:56 | yes Evaluation Count:508 |
| 56-508 |
475 | sslConfigurationChanged(httpReply->sslConfiguration()); executed: sslConfigurationChanged(httpReply->sslConfiguration()); Execution Count:56 | 56 |
476 | | - |
477 | | - |
478 | | - |
479 | if (httpReply->supportsUserProvidedDownloadBuffer() evaluated: httpReply->supportsUserProvidedDownloadBuffer() yes Evaluation Count:352 | yes Evaluation Count:212 |
| 212-352 |
480 | && (downloadBufferMaximumSize > 0) && (httpReply->contentLength() <= downloadBufferMaximumSize)) { partially evaluated: (downloadBufferMaximumSize > 0) yes Evaluation Count:352 | no Evaluation Count:0 |
evaluated: (httpReply->contentLength() <= downloadBufferMaximumSize) yes Evaluation Count:334 | yes Evaluation Count:18 |
| 0-352 |
481 | if (true) { partially evaluated: true yes Evaluation Count:334 | no Evaluation Count:0 |
| 0-334 |
482 | char *buf = new char[httpReply->contentLength()]; | - |
483 | if (buf) { partially evaluated: buf yes Evaluation Count:334 | no Evaluation Count:0 |
| 0-334 |
484 | downloadBuffer = QSharedPointer<char>(buf, downloadBufferDeleter); | - |
485 | httpReply->setUserProvidedDownloadBuffer(buf); | - |
486 | } executed: } Execution Count:334 | 334 |
487 | } else { executed: } Execution Count:334 | 334 |
488 | | - |
489 | } | 0 |
490 | } | - |
491 | | - |
492 | | - |
493 | incomingHeaders = httpReply->header(); | - |
494 | incomingStatusCode = httpReply->statusCode(); | - |
495 | incomingReasonPhrase = httpReply->reasonPhrase(); | - |
496 | isPipeliningUsed = httpReply->isPipeliningUsed(); | - |
497 | incomingContentLength = httpReply->contentLength(); | - |
498 | | - |
499 | downloadMetaData(incomingHeaders, | - |
500 | incomingStatusCode, | - |
501 | incomingReasonPhrase, | - |
502 | isPipeliningUsed, | - |
503 | downloadBuffer, | - |
504 | incomingContentLength); | - |
505 | } executed: } Execution Count:564 | 564 |
506 | | - |
507 | void QHttpThreadDelegate::synchronousHeaderChangedSlot() | - |
508 | { | - |
509 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:74 |
| 0-74 |
510 | return; | 0 |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
515 | | - |
516 | incomingHeaders = httpReply->header(); | - |
517 | incomingStatusCode = httpReply->statusCode(); | - |
518 | incomingReasonPhrase = httpReply->reasonPhrase(); | - |
519 | isPipeliningUsed = httpReply->isPipeliningUsed(); | - |
520 | incomingContentLength = httpReply->contentLength(); | - |
521 | } executed: } Execution Count:74 | 74 |
522 | | - |
523 | | - |
524 | void QHttpThreadDelegate::dataReadProgressSlot(qint64 done, qint64 total) | - |
525 | { | - |
526 | | - |
527 | | - |
528 | if (downloadBuffer.isNull()) evaluated: downloadBuffer.isNull() yes Evaluation Count:11135 | yes Evaluation Count:3163 |
| 3163-11135 |
529 | return; executed: return; Execution Count:11135 | 11135 |
530 | | - |
531 | pendingDownloadProgress->fetchAndAddRelease(1); | - |
532 | downloadProgress(done, total); | - |
533 | } executed: } Execution Count:3163 | 3163 |
534 | | - |
535 | void QHttpThreadDelegate::cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator) | - |
536 | { | - |
537 | authenticationManager->cacheCredentials(request.url(), authenticator); | - |
538 | } executed: } Execution Count:169 | 169 |
539 | | - |
540 | | - |
541 | | - |
542 | void QHttpThreadDelegate::sslErrorsSlot(const QList<QSslError> &errors) | - |
543 | { | - |
544 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:33 |
| 0-33 |
545 | return; | 0 |
546 | | - |
547 | sslConfigurationChanged(httpReply->sslConfiguration()); | - |
548 | | - |
549 | bool ignoreAll = false; | - |
550 | QList<QSslError> specificErrors; | - |
551 | sslErrors(errors, &ignoreAll, &specificErrors); | - |
552 | if (ignoreAll) evaluated: ignoreAll yes Evaluation Count:21 | yes Evaluation Count:12 |
| 12-21 |
553 | httpReply->ignoreSslErrors(); executed: httpReply->ignoreSslErrors(); Execution Count:21 | 21 |
554 | if (!specificErrors.isEmpty()) evaluated: !specificErrors.isEmpty() yes Evaluation Count:6 | yes Evaluation Count:27 |
| 6-27 |
555 | httpReply->ignoreSslErrors(specificErrors); executed: httpReply->ignoreSslErrors(specificErrors); Execution Count:6 | 6 |
556 | } executed: } Execution Count:33 | 33 |
557 | | - |
558 | | - |
559 | void QHttpThreadDelegate::synchronousAuthenticationRequiredSlot(const QHttpNetworkRequest &request, QAuthenticator *a) | - |
560 | { | - |
561 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
562 | return; | 0 |
563 | | - |
564 | (void)request;; | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | | - |
570 | QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedCredentials(httpRequest.url(), a); | - |
571 | if (!credential.isNull()) { evaluated: !credential.isNull() yes Evaluation Count:11 | yes Evaluation Count:6 |
| 6-11 |
572 | a->setUser(credential.user); | - |
573 | a->setPassword(credential.password); | - |
574 | } executed: } Execution Count:11 | 11 |
575 | | - |
576 | | - |
577 | QObject::disconnect(httpReply, "2""authenticationRequired(QHttpNetworkRequest,QAuthenticator*)", | - |
578 | this, "1""synchronousAuthenticationRequiredSlot(QHttpNetworkRequest,QAuthenticator*)"); | - |
579 | } executed: } Execution Count:17 | 17 |
580 | | - |
581 | | - |
582 | void QHttpThreadDelegate::synchronousProxyAuthenticationRequiredSlot(const QNetworkProxy &p, QAuthenticator *a) | - |
583 | { | - |
584 | if (!httpReply) partially evaluated: !httpReply no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
585 | return; | 0 |
586 | | - |
587 | | - |
588 | | - |
589 | | - |
590 | | - |
591 | QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedProxyCredentials(p, a); | - |
592 | if (!credential.isNull()) { partially evaluated: !credential.isNull() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
593 | a->setUser(credential.user); | - |
594 | a->setPassword(credential.password); | - |
595 | } | 0 |
596 | | - |
597 | | - |
598 | QObject::disconnect(httpReply, "2""proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)", | - |
599 | this, "1""synchronousProxyAuthenticationRequiredSlot(QNetworkProxy,QAuthenticator*)"); | - |
600 | } executed: } Execution Count:1 | 1 |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
| | |