summaryrefslogtreecommitdiff
path: root/src/network/access/qnetworkaccesshttpbackend.cpp
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2013-04-30 14:48:22 +0200
committerPeter Hartmann <phartmann@blackberry.com>2013-06-03 12:50:15 +0200
commit054e85bfdae2af37f0c2ee17d131e0b3cb2d2f25 (patch)
treeab51c7b9c845455c94a3997c23da2bb77d0673f1 /src/network/access/qnetworkaccesshttpbackend.cpp
parent84eb6200ff0850db8bab8d32b70e571ca9db2bda (diff)
downloadqt4-tools-4.8-bb10.tar.gz
[BB10-internal] QSslConfiguration: add API to persist and resume SSL sessions4.8-bb10
Session tickets can be cached on the client side for hours (e.g. graph.facebook.com: ~ 24 hours, api.twitter.com: 4 hours), because the server does not need to maintain state. We need public API for it so an application can cache the session (e.g. to disk) and resume a session already with the 1st handshake, saving one network round trip. Task-number: QTBUG-20668 (backport of commit 3be197881f100d1c3c8f3ce00501d7a32eb51119) Change-Id: I4c7f3a749edf0012b52deeb495706e550d24c42d Signed-off-by: Peter Hartmann <phartmann@blackberry.com>
Diffstat (limited to 'src/network/access/qnetworkaccesshttpbackend.cpp')
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp27
1 files changed, 26 insertions, 1 deletions
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