summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkaccessbackend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qnetworkaccessbackend.cpp')
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index 4273e10..60f7dc6 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -46,9 +46,11 @@
#include "qnetworkreply_p.h"
#include "QtCore/qhash.h"
#include "QtCore/qmutex.h"
+#include "QtNetwork/qnetworksession.h"
#include "qnetworkaccesscachebackend_p.h"
#include "qabstractnetworkcache.h"
+#include "qhostinfo.h"
#include "private/qnoncontiguousbytedevice_p.h"
@@ -120,8 +122,11 @@ QNonContiguousByteDevice* QNetworkAccessBackend::createUploadByteDevice()
if (reply->outgoingDataBuffer)
device = QNonContiguousByteDeviceFactory::create(reply->outgoingDataBuffer);
- else
+ else if (reply->outgoingData) {
device = QNonContiguousByteDeviceFactory::create(reply->outgoingData);
+ } else {
+ return 0;
+ }
bool bufferDisallowed =
reply->request.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute,
@@ -322,6 +327,11 @@ void QNetworkAccessBackend::authenticationRequired(QAuthenticator *authenticator
manager->authenticationRequired(this, authenticator);
}
+void QNetworkAccessBackend::cacheCredentials(QAuthenticator *authenticator)
+{
+ manager->addCredentials(this->reply->url, authenticator);
+}
+
void QNetworkAccessBackend::metaDataChanged()
{
reply->metaDataChanged();
@@ -341,4 +351,38 @@ void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors)
#endif
}
+#ifndef QT_NO_BEARERMANAGEMENT
+
+/*!
+ Starts the backend. Returns true if the backend is started. Returns false if the backend
+ could not be started due to an unopened or roaming session. The caller should recall this
+ function once the session has been opened or the roaming process has finished.
+*/
+bool QNetworkAccessBackend::start()
+{
+ if (!manager->networkSession) {
+ open();
+ return true;
+ }
+
+ // This is not ideal.
+ const QString host = reply->url.host();
+ if (host == QLatin1String("localhost") ||
+ QHostAddress(host) == QHostAddress::LocalHost ||
+ QHostAddress(host) == QHostAddress::LocalHostIPv6) {
+ // Don't need an open session for localhost access.
+ open();
+ return true;
+ }
+
+ if (manager->networkSession->isOpen() &&
+ manager->networkSession->state() == QNetworkSession::Connected) {
+ open();
+ return true;
+ }
+
+ return false;
+}
+#endif
+
QT_END_NAMESPACE