summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyimpl.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-11-25 17:00:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-11-25 17:00:40 (GMT)
commit4ab8b588256cfd12c32e166cf15d4ede050222fb (patch)
tree0f4417221e7634c99ffc12a3b4f75672e7e56dc7 /src/network/access/qnetworkreplyimpl.cpp
parent482437316b5deb6ff10577283016fb713cf92efc (diff)
parent062e4383c3b8c7c93e62ad564c47826369aa8a33 (diff)
downloadQt-4ab8b588256cfd12c32e166cf15d4ede050222fb.zip
Qt-4ab8b588256cfd12c32e166cf15d4ede050222fb.tar.gz
Qt-4ab8b588256cfd12c32e166cf15d4ede050222fb.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Fix a missing error-signal when a server is shut down while downloading Ensure that if this is does not have a valid filter when on XP or less HTTP backend: fix build without Qt3 support QNetworkAccessManager: enable synchronous HTTP calls
Diffstat (limited to 'src/network/access/qnetworkreplyimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 5850494..cf6e674 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -85,7 +85,7 @@ void QNetworkReplyImplPrivate::_q_startOperation()
}
#ifndef QT_NO_BEARERMANAGEMENT
- if (!backend->start()) {
+ if (!backend->start()) { // ### we should call that method even if bearer is not used
// backend failed to start because the session state is not Connected.
// QNetworkAccessManager will call reply->backend->start() again for us when the session
// state changes.
@@ -109,11 +109,15 @@ void QNetworkReplyImplPrivate::_q_startOperation()
}
#endif
- if (state != Finished) {
- if (operation == QNetworkAccessManager::GetOperation)
- pendingNotifications.append(NotifyDownstreamReadyWrite);
+ if (backend->isSynchronous()) {
+ state = Finished;
+ } else {
+ if (state != Finished) {
+ if (operation == QNetworkAccessManager::GetOperation)
+ pendingNotifications.append(NotifyDownstreamReadyWrite);
- handleNotifications();
+ handleNotifications();
+ }
}
}
@@ -287,7 +291,25 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
url = request.url();
operation = op;
- if (outgoingData && backend) {
+ q->QIODevice::open(QIODevice::ReadOnly);
+ // Internal code that does a HTTP reply for the synchronous Ajax
+ // in QtWebKit.
+ QVariant synchronousHttpAttribute = req.attribute(
+ static_cast<QNetworkRequest::Attribute>(QNetworkRequest::DownloadBufferAttribute + 1));
+ if (synchronousHttpAttribute.toBool()) {
+ backend->setSynchronous(true);
+ if (outgoingData && outgoingData->isSequential()) {
+ outgoingDataBuffer = new QRingBuffer();
+ QByteArray data;
+ do {
+ data = outgoingData->readAll();
+ if (data.isEmpty())
+ break;
+ outgoingDataBuffer->append(data);
+ } while (1);
+ }
+ }
+ if (outgoingData && backend && !backend->isSynchronous()) {
// there is data to be uploaded, e.g. HTTP POST.
if (!backend->needsResetableUploadData() || !outgoingData->isSequential()) {
@@ -298,7 +320,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
} else {
bool bufferingDisallowed =
req.attribute(QNetworkRequest::DoNotBufferUploadDataAttribute,
- false).toBool();
+ false).toBool();
if (bufferingDisallowed) {
// if a valid content-length header for the request was supplied, we can disable buffering
@@ -323,17 +345,18 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
// for HTTP, we want to send out the request as fast as possible to the network, without
// invoking methods in a QueuedConnection
#ifndef QT_NO_HTTP
- if (qobject_cast<QNetworkAccessHttpBackend *>(backend)) {
+ if (qobject_cast<QNetworkAccessHttpBackend *>(backend) || (backend && backend->isSynchronous())) {
_q_startOperation();
} else {
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
}
#else
- QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
+ if (backend->isSynchronous())
+ _q_startOperation();
+ else
+ QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
#endif // QT_NO_HTTP
- }
-
- q->QIODevice::open(QIODevice::ReadOnly);
+ }
}
void QNetworkReplyImplPrivate::backendNotify(InternalNotifications notification)