Set ConnectInBackground based on request
authorShane Kearns <ext-shane.2.kearns@nokia.com>
Wed, 4 Apr 2012 14:45:22 +0000 (15:45 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 11 Apr 2012 20:18:29 +0000 (22:18 +0200)
Set the QNetworkSession attribute to match the QNetworkRequest that
triggered it.
Currently if there are a mix of normal and background requests queued
and background connections are not allowed by policy:
 - background requests at the head of the queue should fail
 - first foreground request should successfully start a connection
 - remaining requests succeed regardless of background attribute

Change-Id: If0e3ec0b8a5096e3d7cd6df85884c6f53172d233
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
src/network/access/qnetworkreplyimpl.cpp

index c65d790..9fdc29a 100644 (file)
@@ -105,8 +105,11 @@ void QNetworkReplyImplPrivate::_q_startOperation()
             QObject::connect(session, SIGNAL(error(QNetworkSession::SessionError)),
                              q, SLOT(_q_networkSessionFailed()));
 
-            if (!session->isOpen())
+            if (!session->isOpen()) {
+                session->setSessionProperty(QStringLiteral("ConnectInBackground"),
+                    backend->request().attribute(QNetworkRequest::BackgroundRequestAttribute, QVariant::fromValue(false)));
                 session->open();
+            }
         } else {
             qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
             state = Working;