Skip to content

Instantly share code, notes, and snippets.

@guruz
Created May 28, 2015 15:34
Show Gist options
  • Save guruz/c9b2607e9c0fa92006c9 to your computer and use it in GitHub Desktop.
Save guruz/c9b2607e9c0fa92006c9 to your computer and use it in GitHub Desktop.
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 49c6793..09d70e0 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -839,6 +839,10 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
}
errorCode = QNetworkReply::RemoteHostClosedError;
+ } else if (state == QHttpNetworkConnectionChannel::IdleState && !reply) {
+ // This is a perfectly fine thing to happen by "Connection: close" webservers, just retry.
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ return;
} else {
errorCode = QNetworkReply::RemoteHostClosedError;
}
diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp
index 3357948..5bd7539 100644
--- a/src/network/access/qhttpprotocolhandler.cpp
+++ b/src/network/access/qhttpprotocolhandler.cpp
@@ -68,6 +68,13 @@ void QHttpProtocolHandler::_q_receiveReply()
// connection might be closed to signal the end of data
if (socketState == QAbstractSocket::UnconnectedState) {
+#ifndef QT_NO_SSL
+ QSslSocket *sslSocket = qobject_cast<QSslSocket*>(m_socket);
+ if (sslSocket && sslSocket->encryptedBytesAvailable() > 0) {
+ // Make sure data gets decrypted and is then available here.
+ sslSocket->flush();
+ }
+#endif
if (m_socket->bytesAvailable() <= 0) {
if (m_reply->d_func()->state == QHttpNetworkReplyPrivate::ReadingDataState) {
// finish this reply. this case happens when the server did not send a content length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment