summaryrefslogtreecommitdiff
path: root/src/network/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp15
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h4
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp3
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp27
4 files changed, 47 insertions, 2 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 3fc6229e29..d437f6363a 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -50,6 +50,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Oper
QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
: QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0),
autoDecompress(false), pipeliningAllowed(false), withCredentials(true)
+ , m_cacheSslSession(false)
{
}
@@ -64,6 +65,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest
customVerb = other.customVerb;
withCredentials = other.withCredentials;
ssl = other.ssl;
+ m_cacheSslSession = other.m_cacheSslSession;
}
QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate()
@@ -75,7 +77,8 @@ bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &ot
return QHttpNetworkHeaderPrivate::operator==(other)
&& (operation == other.operation)
&& (ssl == other.ssl)
- && (uploadByteDevice == other.uploadByteDevice);
+ && (uploadByteDevice == other.uploadByteDevice)
+ && (m_cacheSslSession == other.m_cacheSslSession);
}
QByteArray QHttpNetworkRequestPrivate::methodName() const
@@ -311,6 +314,16 @@ QNonContiguousByteDevice* QHttpNetworkRequest::uploadByteDevice() const
return d->uploadByteDevice;
}
+bool QHttpNetworkRequest::cacheSslSession()
+{
+ return d->m_cacheSslSession;
+}
+
+void QHttpNetworkRequest::setCacheSslSession(bool cacheSession)
+{
+ d->m_cacheSslSession = cacheSession;
+}
+
int QHttpNetworkRequest::majorVersion() const
{
return 1;
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index e6216db2e3..09dd76e1fa 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -122,6 +122,9 @@ public:
void setUploadByteDevice(QNonContiguousByteDevice *bd);
QNonContiguousByteDevice* uploadByteDevice() const;
+ bool cacheSslSession();
+ void setCacheSslSession(bool cacheSession);
+
private:
QSharedDataPointer<QHttpNetworkRequestPrivate> d;
friend class QHttpNetworkRequestPrivate;
@@ -150,6 +153,7 @@ public:
bool pipeliningAllowed;
bool withCredentials;
bool ssl;
+ bool m_cacheSslSession;
};
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 38d9bc1177..7ace6279d7 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -279,6 +279,9 @@ void QHttpThreadDelegate::startRequest()
#endif
#ifndef QT_NO_OPENSSL
// Set the QSslConfiguration from this QNetworkRequest.
+ if (httpRequest.cacheSslSession())
+ incomingSslConfiguration.d->cacheSslSession = true;
+
if (ssl && incomingSslConfiguration != QSslConfiguration::defaultConfiguration()) {
httpConnection->setSslConfiguration(incomingSslConfiguration);
}
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index f3ae1bcb7f..68200b1f04 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -518,6 +518,9 @@ void QNetworkAccessHttpBackend::postRequest()
QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
httpRequest.setWithCredentials(false);
+ if (request().attribute(static_cast<QNetworkRequest::Attribute>(
+ static_cast<int>(QNetworkRequest::User)-1)).toBool() == true)
+ httpRequest.setCacheSslSession(true);
// Create the HTTP thread delegate
QHttpThreadDelegate *delegate = new QHttpThreadDelegate;
@@ -544,8 +547,15 @@ void QNetworkAccessHttpBackend::postRequest()
#endif
delegate->ssl = ssl;
#ifndef QT_NO_OPENSSL
- if (ssl)
+ if (ssl) {
delegate->incomingSslConfiguration = request().sslConfiguration();
+ QNetworkRequest::Attribute sslSessionAttribute =
+ static_cast<QNetworkRequest::Attribute>(
+ static_cast<int>(QNetworkRequest::User)-3);
+ QByteArray sslSession = request().attribute(sslSessionAttribute).toByteArray();
+ if (!sslSession.isEmpty())
+ delegate->incomingSslConfiguration.d->sslSession = sslSession;
+ }
#endif
// Do we use synchronous HTTP?
@@ -913,6 +923,21 @@ void QNetworkAccessHttpBackend::replySslConfigurationChanged(const QSslConfigura
*pendingSslConfiguration = c;
else if (!c.isNull())
pendingSslConfiguration = new QSslConfiguration(c);
+
+ if (c.d->sslSession.size() > 0) {
+ QNetworkRequest::Attribute sslSessionAttribute =
+ static_cast<QNetworkRequest::Attribute>(
+ static_cast<int>(QNetworkRequest::User)-3);
+ QNetworkRequest::Attribute sslSessionTicketLifeTimeHintAttribute =
+ static_cast<QNetworkRequest::Attribute>(
+ static_cast<int>(QNetworkRequest::User)-2);
+ // only set the attribute once; this method is called several times
+ if (attribute(sslSessionAttribute).toByteArray().isEmpty()) {
+ setAttribute(sslSessionAttribute, c.d->sslSession);
+ setAttribute(sslSessionTicketLifeTimeHintAttribute,
+ c.d->sslSessionTicketLifeTimeHint);
+ }
+ }
}
#endif