| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessbackend.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qnetworkaccessbackend_p.h" | - | ||||||||||||
| 41 | #include "qnetworkaccessmanager_p.h" | - | ||||||||||||
| 42 | #include "qnetworkconfigmanager.h" | - | ||||||||||||
| 43 | #include "qnetworkrequest.h" | - | ||||||||||||
| 44 | #include "qnetworkreply.h" | - | ||||||||||||
| 45 | #include "qnetworkreply_p.h" | - | ||||||||||||
| 46 | #include "QtCore/qmutex.h" | - | ||||||||||||
| 47 | #include "QtCore/qstringlist.h" | - | ||||||||||||
| 48 | #include "QtNetwork/private/qnetworksession_p.h" | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | #include "qnetworkaccesscachebackend_p.h" | - | ||||||||||||
| 51 | #include "qabstractnetworkcache.h" | - | ||||||||||||
| 52 | #include "qhostinfo.h" | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | #include "private/qnoncontiguousbytedevice_p.h" | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | class QNetworkAccessBackendFactoryData: public QList<QNetworkAccessBackendFactory *> | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | public: | - | ||||||||||||
| 61 | QNetworkAccessBackendFactoryData() : mutex(QMutex::Recursive) | - | ||||||||||||
| 62 | { | - | ||||||||||||
| 63 | valid.ref(); | - | ||||||||||||
| 64 | } executed 9 times by 9 tests: end of blockExecuted by:
| 9 | ||||||||||||
| 65 | ~QNetworkAccessBackendFactoryData() | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | QMutexLocker locker(&mutex); // why do we need to lock? | - | ||||||||||||
| 68 | valid.deref(); | - | ||||||||||||
| 69 | } executed 10 times by 10 tests: end of blockExecuted by:
| 10 | ||||||||||||
| 70 | - | |||||||||||||
| 71 | QMutex mutex; | - | ||||||||||||
| 72 | //this is used to avoid (re)constructing factory data from destructors of other global classes | - | ||||||||||||
| 73 | static QBasicAtomicInt valid; | - | ||||||||||||
| 74 | }; | - | ||||||||||||
| 75 | Q_GLOBAL_STATIC(QNetworkAccessBackendFactoryData, factoryData) executed 10 times by 10 tests: end of blockExecuted by:
executed 10 times by 10 tests: guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 438 times by 20 tests: return &holder.value;Executed by:
| 0-438 | ||||||||||||
| 76 | QBasicAtomicInt QNetworkAccessBackendFactoryData::valid = Q_BASIC_ATOMIC_INITIALIZER(0); | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | QNetworkAccessBackendFactory::QNetworkAccessBackendFactory() | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||||||||
| 81 | factoryData()->append(this); | - | ||||||||||||
| 82 | } executed 27 times by 9 tests: end of blockExecuted by:
| 27 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory() | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | if (QNetworkAccessBackendFactoryData::valid.load()) {
| 0-30 | ||||||||||||
| 87 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||||||||
| 88 | factoryData()->removeAll(this); | - | ||||||||||||
| 89 | } executed 30 times by 10 tests: end of blockExecuted by:
| 30 | ||||||||||||
| 90 | } executed 30 times by 10 tests: end of blockExecuted by:
| 30 | ||||||||||||
| 91 | - | |||||||||||||
| 92 | QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op, | - | ||||||||||||
| 93 | const QNetworkRequest &request) | - | ||||||||||||
| 94 | { | - | ||||||||||||
| 95 | if (QNetworkAccessBackendFactoryData::valid.load()) {
| 0-108 | ||||||||||||
| 96 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||||||||
| 97 | QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(), | - | ||||||||||||
| 98 | end = factoryData()->constEnd(); | - | ||||||||||||
| 99 | while (it != end) {
| 4-209 | ||||||||||||
| 100 | QNetworkAccessBackend *backend = (*it)->create(op, request); | - | ||||||||||||
| 101 | if (backend) {
| 104-105 | ||||||||||||
| 102 | backend->manager = this; | - | ||||||||||||
| 103 | return backend; // found a factory that handled our request executed 104 times by 1 test: return backend;Executed by:
| 104 | ||||||||||||
| 104 | } | - | ||||||||||||
| 105 | ++it; | - | ||||||||||||
| 106 | } executed 105 times by 1 test: end of blockExecuted by:
| 105 | ||||||||||||
| 107 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||
| 108 | return 0; executed 4 times by 1 test: return 0;Executed by:
| 4 | ||||||||||||
| 109 | } | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | QStringList QNetworkAccessManagerPrivate::backendSupportedSchemes() const | - | ||||||||||||
| 112 | { | - | ||||||||||||
| 113 | if (QNetworkAccessBackendFactoryData::valid.load()) {
| 0 | ||||||||||||
| 114 | QMutexLocker locker(&factoryData()->mutex); | - | ||||||||||||
| 115 | QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(); | - | ||||||||||||
| 116 | QNetworkAccessBackendFactoryData::ConstIterator end = factoryData()->constEnd(); | - | ||||||||||||
| 117 | QStringList schemes; | - | ||||||||||||
| 118 | while (it != end) {
| 0 | ||||||||||||
| 119 | schemes += (*it)->supportedSchemes(); | - | ||||||||||||
| 120 | ++it; | - | ||||||||||||
| 121 | } never executed: end of block | 0 | ||||||||||||
| 122 | return schemes; never executed: return schemes; | 0 | ||||||||||||
| 123 | } | - | ||||||||||||
| 124 | return QStringList(); never executed: return QStringList(); | 0 | ||||||||||||
| 125 | } | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice() | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | if (reply->outgoingDataBuffer)
| 0-59 | ||||||||||||
| 130 | uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingDataBuffer); never executed: uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingDataBuffer); | 0 | ||||||||||||
| 131 | else if (reply->outgoingData) {
| 0-59 | ||||||||||||
| 132 | uploadByteDevice = QNonContiguousByteDeviceFactory::createShared(reply->outgoingData); | - | ||||||||||||
| 133 | } else { executed 59 times by 1 test: end of blockExecuted by:
| 59 | ||||||||||||
| 134 | return 0; never executed: return 0; | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | // We want signal emissions only for normal asynchronous uploads | - | ||||||||||||
| 138 | if (!isSynchronous())
| 0-59 | ||||||||||||
| 139 | connect(uploadByteDevice.data(), SIGNAL(readProgress(qint64,qint64)), this, SLOT(emitReplyUploadProgress(qint64,qint64))); executed 59 times by 1 test: connect(uploadByteDevice.data(), qFlagLocation("2""readProgress(qint64,qint64)" "\0" __FILE__ ":" "139"), this, qFlagLocation("1""emitReplyUploadProgress(qint64,qint64)" "\0" __FILE__ ":" "139"));Executed by:
| 59 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | return uploadByteDevice.data(); executed 59 times by 1 test: return uploadByteDevice.data();Executed by:
| 59 | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | // need to have this function since the reply is a private member variable | - | ||||||||||||
| 145 | // and the special backends need to access this. | - | ||||||||||||
| 146 | void QNetworkAccessBackend::emitReplyUploadProgress(qint64 bytesSent, qint64 bytesTotal) | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | if (reply->isFinished)
| 0-1053 | ||||||||||||
| 149 | return; never executed: return; | 0 | ||||||||||||
| 150 | reply->emitUploadProgress(bytesSent, bytesTotal); | - | ||||||||||||
| 151 | } executed 1053 times by 1 test: end of blockExecuted by:
| 1053 | ||||||||||||
| 152 | - | |||||||||||||
| 153 | QNetworkAccessBackend::QNetworkAccessBackend() | - | ||||||||||||
| 154 | : manager(0) | - | ||||||||||||
| 155 | , reply(0) | - | ||||||||||||
| 156 | , synchronous(false) | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | } executed 118 times by 3 tests: end of blockExecuted by:
| 118 | ||||||||||||
| 159 | - | |||||||||||||
| 160 | QNetworkAccessBackend::~QNetworkAccessBackend() | - | ||||||||||||
| 161 | { | - | ||||||||||||
| 162 | } | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | void QNetworkAccessBackend::downstreamReadyWrite() | - | ||||||||||||
| 165 | { | - | ||||||||||||
| 166 | // do nothing | - | ||||||||||||
| 167 | } | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | void QNetworkAccessBackend::setDownstreamLimited(bool b) | - | ||||||||||||
| 170 | { | - | ||||||||||||
| 171 | Q_UNUSED(b); | - | ||||||||||||
| 172 | // do nothing | - | ||||||||||||
| 173 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||
| 174 | - | |||||||||||||
| 175 | void QNetworkAccessBackend::copyFinished(QIODevice *) | - | ||||||||||||
| 176 | { | - | ||||||||||||
| 177 | // do nothing | - | ||||||||||||
| 178 | } | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | void QNetworkAccessBackend::ignoreSslErrors() | - | ||||||||||||
| 181 | { | - | ||||||||||||
| 182 | // do nothing | - | ||||||||||||
| 183 | } | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | void QNetworkAccessBackend::ignoreSslErrors(const QList<QSslError> &errors) | - | ||||||||||||
| 186 | { | - | ||||||||||||
| 187 | Q_UNUSED(errors); | - | ||||||||||||
| 188 | // do nothing | - | ||||||||||||
| 189 | } never executed: end of block | 0 | ||||||||||||
| 190 | - | |||||||||||||
| 191 | void QNetworkAccessBackend::fetchSslConfiguration(QSslConfiguration &) const | - | ||||||||||||
| 192 | { | - | ||||||||||||
| 193 | // do nothing | - | ||||||||||||
| 194 | } | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | void QNetworkAccessBackend::setSslConfiguration(const QSslConfiguration &) | - | ||||||||||||
| 197 | { | - | ||||||||||||
| 198 | // do nothing | - | ||||||||||||
| 199 | } | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | QNetworkCacheMetaData QNetworkAccessBackend::fetchCacheMetaData(const QNetworkCacheMetaData &) const | - | ||||||||||||
| 202 | { | - | ||||||||||||
| 203 | return QNetworkCacheMetaData(); never executed: return QNetworkCacheMetaData(); | 0 | ||||||||||||
| 204 | } | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | QNetworkAccessManager::Operation QNetworkAccessBackend::operation() const | - | ||||||||||||
| 207 | { | - | ||||||||||||
| 208 | return reply->operation; executed 462 times by 2 tests: return reply->operation;Executed by:
| 462 | ||||||||||||
| 209 | } | - | ||||||||||||
| 210 | - | |||||||||||||
| 211 | QNetworkRequest QNetworkAccessBackend::request() const | - | ||||||||||||
| 212 | { | - | ||||||||||||
| 213 | return reply->request; executed 125 times by 2 tests: return reply->request;Executed by:
| 125 | ||||||||||||
| 214 | } | - | ||||||||||||
| 215 | - | |||||||||||||
| 216 | #ifndef QT_NO_NETWORKPROXY | - | ||||||||||||
| 217 | QList<QNetworkProxy> QNetworkAccessBackend::proxyList() const | - | ||||||||||||
| 218 | { | - | ||||||||||||
| 219 | return reply->proxyList; executed 53 times by 1 test: return reply->proxyList;Executed by:
| 53 | ||||||||||||
| 220 | } | - | ||||||||||||
| 221 | #endif | - | ||||||||||||
| 222 | - | |||||||||||||
| 223 | QAbstractNetworkCache *QNetworkAccessBackend::networkCache() const | - | ||||||||||||
| 224 | { | - | ||||||||||||
| 225 | if (!manager)
| 0-43 | ||||||||||||
| 226 | return 0; never executed: return 0; | 0 | ||||||||||||
| 227 | return manager->networkCache; executed 43 times by 2 tests: return manager->networkCache;Executed by:
| 43 | ||||||||||||
| 228 | } | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | void QNetworkAccessBackend::setCachingEnabled(bool enable) | - | ||||||||||||
| 231 | { | - | ||||||||||||
| 232 | reply->setCachingEnabled(enable); | - | ||||||||||||
| 233 | } executed 43 times by 2 tests: end of blockExecuted by:
| 43 | ||||||||||||
| 234 | - | |||||||||||||
| 235 | bool QNetworkAccessBackend::isCachingEnabled() const | - | ||||||||||||
| 236 | { | - | ||||||||||||
| 237 | return reply->isCachingEnabled(); never executed: return reply->isCachingEnabled(); | 0 | ||||||||||||
| 238 | } | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | qint64 QNetworkAccessBackend::nextDownstreamBlockSize() const | - | ||||||||||||
| 241 | { | - | ||||||||||||
| 242 | return reply->nextDownstreamBlockSize(); executed 38 times by 1 test: return reply->nextDownstreamBlockSize();Executed by:
| 38 | ||||||||||||
| 243 | } | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | void QNetworkAccessBackend::writeDownstreamData(QByteDataBuffer &list) | - | ||||||||||||
| 246 | { | - | ||||||||||||
| 247 | reply->appendDownstreamData(list); | - | ||||||||||||
| 248 | } executed 488 times by 1 test: end of blockExecuted by:
| 488 | ||||||||||||
| 249 | - | |||||||||||||
| 250 | void QNetworkAccessBackend::writeDownstreamData(QIODevice *data) | - | ||||||||||||
| 251 | { | - | ||||||||||||
| 252 | reply->appendDownstreamData(data); | - | ||||||||||||
| 253 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||
| 254 | - | |||||||||||||
| 255 | // not actually appending data, it was already written to the user buffer | - | ||||||||||||
| 256 | void QNetworkAccessBackend::writeDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal) | - | ||||||||||||
| 257 | { | - | ||||||||||||
| 258 | reply->appendDownstreamDataDownloadBuffer(bytesReceived, bytesTotal); | - | ||||||||||||
| 259 | } never executed: end of block | 0 | ||||||||||||
| 260 | - | |||||||||||||
| 261 | char* QNetworkAccessBackend::getDownloadBuffer(qint64 size) | - | ||||||||||||
| 262 | { | - | ||||||||||||
| 263 | return reply->getDownloadBuffer(size); never executed: return reply->getDownloadBuffer(size); | 0 | ||||||||||||
| 264 | } | - | ||||||||||||
| 265 | - | |||||||||||||
| 266 | QVariant QNetworkAccessBackend::header(QNetworkRequest::KnownHeaders header) const | - | ||||||||||||
| 267 | { | - | ||||||||||||
| 268 | return reply->q_func()->header(header); never executed: return reply->q_func()->header(header); | 0 | ||||||||||||
| 269 | } | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | void QNetworkAccessBackend::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value) | - | ||||||||||||
| 272 | { | - | ||||||||||||
| 273 | reply->setCookedHeader(header, value); | - | ||||||||||||
| 274 | } executed 69 times by 1 test: end of blockExecuted by:
| 69 | ||||||||||||
| 275 | - | |||||||||||||
| 276 | bool QNetworkAccessBackend::hasRawHeader(const QByteArray &headerName) const | - | ||||||||||||
| 277 | { | - | ||||||||||||
| 278 | return reply->q_func()->hasRawHeader(headerName); never executed: return reply->q_func()->hasRawHeader(headerName); | 0 | ||||||||||||
| 279 | } | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | QByteArray QNetworkAccessBackend::rawHeader(const QByteArray &headerName) const | - | ||||||||||||
| 282 | { | - | ||||||||||||
| 283 | return reply->q_func()->rawHeader(headerName); never executed: return reply->q_func()->rawHeader(headerName); | 0 | ||||||||||||
| 284 | } | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | QList<QByteArray> QNetworkAccessBackend::rawHeaderList() const | - | ||||||||||||
| 287 | { | - | ||||||||||||
| 288 | return reply->q_func()->rawHeaderList(); never executed: return reply->q_func()->rawHeaderList(); | 0 | ||||||||||||
| 289 | } | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | void QNetworkAccessBackend::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue) | - | ||||||||||||
| 292 | { | - | ||||||||||||
| 293 | reply->setRawHeader(headerName, headerValue); | - | ||||||||||||
| 294 | } executed 36 times by 2 tests: end of blockExecuted by:
| 36 | ||||||||||||
| 295 | - | |||||||||||||
| 296 | QVariant QNetworkAccessBackend::attribute(QNetworkRequest::Attribute code) const | - | ||||||||||||
| 297 | { | - | ||||||||||||
| 298 | return reply->q_func()->attribute(code); never executed: return reply->q_func()->attribute(code); | 0 | ||||||||||||
| 299 | } | - | ||||||||||||
| 300 | - | |||||||||||||
| 301 | void QNetworkAccessBackend::setAttribute(QNetworkRequest::Attribute code, const QVariant &value) | - | ||||||||||||
| 302 | { | - | ||||||||||||
| 303 | if (value.isValid())
| 8-25 | ||||||||||||
| 304 | reply->attributes.insert(code, value); executed 25 times by 2 tests: reply->attributes.insert(code, value);Executed by:
| 25 | ||||||||||||
| 305 | else | - | ||||||||||||
| 306 | reply->attributes.remove(code); executed 8 times by 1 test: reply->attributes.remove(code);Executed by:
| 8 | ||||||||||||
| 307 | } | - | ||||||||||||
| 308 | QUrl QNetworkAccessBackend::url() const | - | ||||||||||||
| 309 | { | - | ||||||||||||
| 310 | return reply->url; executed 391 times by 2 tests: return reply->url;Executed by:
| 391 | ||||||||||||
| 311 | } | - | ||||||||||||
| 312 | - | |||||||||||||
| 313 | void QNetworkAccessBackend::setUrl(const QUrl &url) | - | ||||||||||||
| 314 | { | - | ||||||||||||
| 315 | reply->url = url; | - | ||||||||||||
| 316 | } executed 50 times by 1 test: end of blockExecuted by:
| 50 | ||||||||||||
| 317 | - | |||||||||||||
| 318 | void QNetworkAccessBackend::finished() | - | ||||||||||||
| 319 | { | - | ||||||||||||
| 320 | reply->finished(); | - | ||||||||||||
| 321 | } executed 114 times by 2 tests: end of blockExecuted by:
| 114 | ||||||||||||
| 322 | - | |||||||||||||
| 323 | void QNetworkAccessBackend::error(QNetworkReply::NetworkError code, const QString &errorString) | - | ||||||||||||
| 324 | { | - | ||||||||||||
| 325 | reply->error(code, errorString); | - | ||||||||||||
| 326 | } executed 17 times by 2 tests: end of blockExecuted by:
| 17 | ||||||||||||
| 327 | - | |||||||||||||
| 328 | #ifndef QT_NO_NETWORKPROXY | - | ||||||||||||
| 329 | void QNetworkAccessBackend::proxyAuthenticationRequired(const QNetworkProxy &proxy, | - | ||||||||||||
| 330 | QAuthenticator *authenticator) | - | ||||||||||||
| 331 | { | - | ||||||||||||
| 332 | manager->proxyAuthenticationRequired(QUrl(), proxy, synchronous, authenticator, &reply->lastProxyAuthentication); | - | ||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||
| 334 | #endif | - | ||||||||||||
| 335 | - | |||||||||||||
| 336 | void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator) | - | ||||||||||||
| 337 | { | - | ||||||||||||
| 338 | manager->authenticationRequired(authenticator, reply->q_func(), synchronous, reply->url, &reply->urlForLastAuthentication); | - | ||||||||||||
| 339 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||
| 340 | - | |||||||||||||
| 341 | void QNetworkAccessBackend::metaDataChanged() | - | ||||||||||||
| 342 | { | - | ||||||||||||
| 343 | reply->metaDataChanged(); | - | ||||||||||||
| 344 | } executed 54 times by 2 tests: end of blockExecuted by:
| 54 | ||||||||||||
| 345 | - | |||||||||||||
| 346 | void QNetworkAccessBackend::redirectionRequested(const QUrl &target) | - | ||||||||||||
| 347 | { | - | ||||||||||||
| 348 | reply->redirectionRequested(target); | - | ||||||||||||
| 349 | } never executed: end of block | 0 | ||||||||||||
| 350 | - | |||||||||||||
| 351 | void QNetworkAccessBackend::encrypted() | - | ||||||||||||
| 352 | { | - | ||||||||||||
| 353 | #ifndef QT_NO_SSL | - | ||||||||||||
| 354 | reply->encrypted(); | - | ||||||||||||
| 355 | #endif | - | ||||||||||||
| 356 | } never executed: end of block | 0 | ||||||||||||
| 357 | - | |||||||||||||
| 358 | void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors) | - | ||||||||||||
| 359 | { | - | ||||||||||||
| 360 | #ifndef QT_NO_SSL | - | ||||||||||||
| 361 | reply->sslErrors(errors); | - | ||||||||||||
| 362 | #else | - | ||||||||||||
| 363 | Q_UNUSED(errors); | - | ||||||||||||
| 364 | #endif | - | ||||||||||||
| 365 | } never executed: end of block | 0 | ||||||||||||
| 366 | - | |||||||||||||
| 367 | /*! | - | ||||||||||||
| 368 | Starts the backend. Returns \c true if the backend is started. Returns \c false if the backend | - | ||||||||||||
| 369 | could not be started due to an unopened or roaming session. The caller should recall this | - | ||||||||||||
| 370 | function once the session has been opened or the roaming process has finished. | - | ||||||||||||
| 371 | */ | - | ||||||||||||
| 372 | bool QNetworkAccessBackend::start() | - | ||||||||||||
| 373 | { | - | ||||||||||||
| 374 | #ifndef QT_NO_BEARERMANAGEMENT | - | ||||||||||||
| 375 | // For bearer, check if session start is required | - | ||||||||||||
| 376 | QSharedPointer<QNetworkSession> networkSession(manager->getNetworkSession()); | - | ||||||||||||
| 377 | if (networkSession) {
| 0-119 | ||||||||||||
| 378 | // session required | - | ||||||||||||
| 379 | if (networkSession->isOpen() &&
| 3-116 | ||||||||||||
| 380 | networkSession->state() == QNetworkSession::Connected) {
| 0-116 | ||||||||||||
| 381 | // Session is already open and ready to use. | - | ||||||||||||
| 382 | // copy network session down to the backend | - | ||||||||||||
| 383 | setProperty("_q_networksession", QVariant::fromValue(networkSession)); | - | ||||||||||||
| 384 | } else { executed 116 times by 2 tests: end of blockExecuted by:
| 116 | ||||||||||||
| 385 | // Session not ready, but can skip for loopback connections | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | // This is not ideal. | - | ||||||||||||
| 388 | // Don't need an open session for localhost access. | - | ||||||||||||
| 389 | if (!reply->url.isLocalFile()) {
| 0-3 | ||||||||||||
| 390 | const QString host = reply->url.host(); | - | ||||||||||||
| 391 | if (host != QLatin1String("localhost") && !QHostAddress(host).isLoopback())
| 0-3 | ||||||||||||
| 392 | return false; // need to wait for session to be opened executed 3 times by 1 test: return false;Executed by:
| 3 | ||||||||||||
| 393 | } never executed: end of block | 0 | ||||||||||||
| 394 | } never executed: end of block | 0 | ||||||||||||
| 395 | } | - | ||||||||||||
| 396 | #endif | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | #ifndef QT_NO_NETWORKPROXY | - | ||||||||||||
| 399 | #ifndef QT_NO_BEARERMANAGEMENT | - | ||||||||||||
| 400 | // Get the proxy settings from the network session (in the case of service networks, | - | ||||||||||||
| 401 | // the proxy settings change depending which AP was activated) | - | ||||||||||||
| 402 | QNetworkSession *session = networkSession.data(); | - | ||||||||||||
| 403 | QNetworkConfiguration config; | - | ||||||||||||
| 404 | if (session) {
| 0-116 | ||||||||||||
| 405 | QNetworkConfigurationManager configManager; | - | ||||||||||||
| 406 | // The active configuration tells us what IAP is in use | - | ||||||||||||
| 407 | QVariant v = session->sessionProperty(QLatin1String("ActiveConfiguration")); | - | ||||||||||||
| 408 | if (v.isValid())
| 0-116 | ||||||||||||
| 409 | config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v)); executed 116 times by 2 tests: config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v));Executed by:
| 116 | ||||||||||||
| 410 | // Fallback to using the configuration if no active configuration | - | ||||||||||||
| 411 | if (!config.isValid())
| 0-116 | ||||||||||||
| 412 | config = session->configuration(); never executed: config = session->configuration(); | 0 | ||||||||||||
| 413 | // or unspecified configuration if that is no good either | - | ||||||||||||
| 414 | if (!config.isValid())
| 0-116 | ||||||||||||
| 415 | config = QNetworkConfiguration(); never executed: config = QNetworkConfiguration(); | 0 | ||||||||||||
| 416 | } executed 116 times by 2 tests: end of blockExecuted by:
| 116 | ||||||||||||
| 417 | reply->proxyList = manager->queryProxy(QNetworkProxyQuery(config, url())); | - | ||||||||||||
| 418 | #else // QT_NO_BEARERMANAGEMENT | - | ||||||||||||
| 419 | // Without bearer management, the proxy depends only on the url | - | ||||||||||||
| 420 | reply->proxyList = manager->queryProxy(QNetworkProxyQuery(url())); | - | ||||||||||||
| 421 | #endif | - | ||||||||||||
| 422 | #endif | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | // now start the request | - | ||||||||||||
| 425 | open(); | - | ||||||||||||
| 426 | return true; executed 116 times by 2 tests: return true;Executed by:
| 116 | ||||||||||||
| 427 | } | - | ||||||||||||
| 428 | - | |||||||||||||
| 429 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |