Fix race in http connection channel
authorShane Kearns <shane.kearns@accenture.com>
Mon, 19 Dec 2011 15:35:52 +0000 (15:35 +0000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 22 Dec 2011 14:56:08 +0000 (15:56 +0100)
When authentication is cancelled, close the channel instead of the
underlying socket.
The previous behaviour could result in further requests being sent
on the closed socket, which caused errors in case of https over a proxy.

Change-Id: I3dbfc164de4fb29a426c06acaac8f29b9da1d705
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
src/network/access/qhttpnetworkconnection.cpp
src/network/access/qhttpnetworkconnectionchannel.cpp

index 4a8d672..c1544f0 100644 (file)
@@ -482,7 +482,6 @@ bool QHttpNetworkConnectionPrivate::handleAuthenticateChallenge(QAbstractSocket
             reply->d_func()->errorString = errorDetail(errorCode, socket);
             emit reply->finishedWithError(errorCode, reply->d_func()->errorString);
             // ### at this point the reply could be deleted
-            socket->close();
             return true;
         }
         //resend the request
index 02c1cac..07e190a 100644 (file)
@@ -793,6 +793,9 @@ void QHttpNetworkConnectionChannel::handleStatus()
                     closeAndResendCurrentRequest();
                     QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
                 }
+            } else {
+                //authentication cancelled, close the channel.
+                close();
             }
         } else {
             emit reply->headerChanged();