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