summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkconnectionchannel.cpp
diff options
context:
space:
mode:
authorMartin Petersson <Martin.Petersson@nokia.com>2012-03-01 10:36:38 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-13 10:11:22 +0100
commitc68737add39360040e5b0cd93f01f229d6a8bbc9 (patch)
treed062858c0a1700121c0799c463df6acb41c917b3 /src/network/access/qhttpnetworkconnectionchannel.cpp
parent8be558e99d69fbfda495882e1bda1c64585485a6 (diff)
QNam: only init channels when needed.
Each channel will create a socket that will allocate memory for the read and write buffers. This change will instead initialize channels only when they are needed. Change-Id: I112b4c7b944a7dd345414f06260c92803394eaed Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp67
1 files changed, 65 insertions, 2 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 3991bffa47..a009222bd5 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE
QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel()
: socket(0)
, ssl(false)
+ , isInitialized(false)
, state(IdleState)
, reply(0)
, written(0)
@@ -152,19 +153,38 @@ void QHttpNetworkConnectionChannel::init()
QObject::connect(sslSocket, SIGNAL(encryptedBytesWritten(qint64)),
this, SLOT(_q_encryptedBytesWritten(qint64)),
Qt::DirectConnection);
+
+ if (ignoreAllSslErrors)
+ sslSocket->ignoreSslErrors();
+
+ if (!ignoreSslErrorsList.isEmpty())
+ sslSocket->ignoreSslErrors(ignoreSslErrorsList);
+
+ if (!sslConfiguration.isNull())
+ sslSocket->setSslConfiguration(sslConfiguration);
}
+
#endif
+
+#ifndef QT_NO_NETWORKPROXY
+ if (proxy.type() != QNetworkProxy::NoProxy)
+ socket->setProxy(proxy);
+#endif
+ isInitialized = true;
}
void QHttpNetworkConnectionChannel::close()
{
- if (socket->state() == QAbstractSocket::UnconnectedState)
+ if (!socket)
+ state = QHttpNetworkConnectionChannel::IdleState;
+ else if (socket->state() == QAbstractSocket::UnconnectedState)
state = QHttpNetworkConnectionChannel::IdleState;
else
state = QHttpNetworkConnectionChannel::ClosingState;
- socket->close();
+ if (socket)
+ socket->close();
}
@@ -527,6 +547,9 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF()
bool QHttpNetworkConnectionChannel::ensureConnection()
{
+ if (!isInitialized)
+ init();
+
QAbstractSocket::SocketState socketState = socket->state();
// resend this request after we receive the disconnected signal
@@ -835,6 +858,46 @@ bool QHttpNetworkConnectionChannel::resetUploadData()
}
}
+#ifndef QT_NO_NETWORKPROXY
+
+void QHttpNetworkConnectionChannel::setProxy(const QNetworkProxy &networkProxy)
+{
+ if (socket)
+ socket->setProxy(networkProxy);
+
+ proxy = networkProxy;
+}
+
+#endif
+
+#ifndef QT_NO_SSL
+
+void QHttpNetworkConnectionChannel::ignoreSslErrors()
+{
+ if (socket)
+ static_cast<QSslSocket *>(socket)->ignoreSslErrors();
+
+ ignoreAllSslErrors = true;
+}
+
+
+void QHttpNetworkConnectionChannel::ignoreSslErrors(const QList<QSslError> &errors)
+{
+ if (socket)
+ static_cast<QSslSocket *>(socket)->ignoreSslErrors(errors);
+
+ ignoreSslErrorsList = errors;
+}
+
+void QHttpNetworkConnectionChannel::setSslConfiguration(const QSslConfiguration &config)
+{
+ if (socket)
+ static_cast<QSslSocket *>(socket)->setSslConfiguration(config);
+
+ sslConfiguration = config;
+}
+
+#endif
void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair)
{