summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkconnectionchannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 0820a8d63e..b4eda3477e 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -272,7 +272,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
QAbstractSocket::SocketState socketState = socket->state();
// resend this request after we receive the disconnected signal
- if (socketState == QAbstractSocket::ClosingState) {
+ // If !socket->isOpen() then we have already called close() on the socket, but there was still a
+ // pending connectToHost() for which we hadn't seen a connected() signal, yet. The connected()
+ // has now arrived (as indicated by socketState != ClosingState), but we cannot send anything on
+ // such a socket anymore.
+ if (socketState == QAbstractSocket::ClosingState ||
+ (socketState != QAbstractSocket::UnconnectedState && !socket->isOpen())) {
if (reply)
resendCurrent = true;
return false;
@@ -531,6 +536,20 @@ void QHttpNetworkConnectionChannel::handleStatus()
bool resend = false;
switch (statusCode) {
+ case 301:
+ case 302:
+ case 303:
+ case 305:
+ case 307: {
+ // Parse the response headers and get the "location" url
+ QUrl redirectUrl = connection->d_func()->parseRedirectResponse(socket, reply);
+ if (redirectUrl.isValid())
+ reply->setRedirectUrl(redirectUrl);
+
+ if (qobject_cast<QHttpNetworkConnection *>(connection))
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ break;
+ }
case 401: // auth required
case 407: // proxy auth required
if (connection->d_func()->handleAuthenticateChallenge(socket, reply, (statusCode == 407), resend)) {