summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkreply.cpp
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2014-01-22 14:54:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-19 21:44:15 +0100
commit1de244ea65f1b40c488fe92b29170c1b1d447233 (patch)
treea01d233e33847cf8709b6130ad7fa4656ff348de /src/network/access/qhttpnetworkreply.cpp
parent42789d04a3078652594b8e06f520d7dd5e8021c5 (diff)
network: add support for the SPDY protocol
Currently the only supported SPDY version is 3.0. The feature needs to be enabled explicitly via QNetworkRequest::SpdyAllowedAttribute. Whether SPDY actually was used can be determined via QNetworkRequest::SpdyWasUsedAttribute from a QNetworkReply once it has been started (i.e. after the encrypted() signal has been received). Whether SPDY can be used will be determined during the SSL handshake through the TLS NPN extension (see separate commit). The following things from SPDY have not been enabled currently: * server push is not implemented, it has never been seen in the wild; in that case we just reject a stream pushed by the server, which is legit. * settings are not persisted across SPDY sessions. In practice this means that the server sends a small message upon session start telling us e.g. the number of concurrent connections. * SSL client certificates are not supported. Task-number: QTBUG-18714 [ChangeLog][QtNetwork] Added support for the SPDY protocol (version 3.0). Change-Id: I81bbe0495c24ed84e9cf8af3a9dbd63ca1e93d0d Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/access/qhttpnetworkreply.cpp')
-rw-r--r--src/network/access/qhttpnetworkreply.cpp50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 1b9e1f5a53..2a7e6ed638 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -265,6 +265,16 @@ bool QHttpNetworkReply::isPipeliningUsed() const
return d_func()->pipeliningUsed;
}
+bool QHttpNetworkReply::isSpdyUsed() const
+{
+ return d_func()->spdyUsed;
+}
+
+void QHttpNetworkReply::setSpdyWasUsed(bool spdy)
+{
+ d_func()->spdyUsed = spdy;
+}
+
QHttpNetworkConnection* QHttpNetworkReply::connection()
{
return d_func()->connection;
@@ -281,9 +291,15 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
connectionCloseEnabled(true),
forceConnectionCloseEnabled(false),
lastChunkRead(false),
- currentChunkSize(0), currentChunkRead(0), readBufferMaxSize(0), connection(0),
+ currentChunkSize(0), currentChunkRead(0), readBufferMaxSize(0),
+ windowSizeDownload(65536), // 64K initial window size according to SPDY standard
+ windowSizeUpload(65536), // 64K initial window size according to SPDY standard
+ currentlyReceivedDataInWindow(0),
+ currentlyUploadedDataInWindow(0),
+ totallyUploadedData(0),
+ connection(0),
autoDecompress(false), responseData(), requestIsPrepared(false)
- ,pipeliningUsed(false), downstreamLimited(false)
+ ,pipeliningUsed(false), spdyUsed(false), downstreamLimited(false)
,userProvidedDownloadBuffer(0)
#ifndef QT_NO_COMPRESS
,inflateStrm(0)
@@ -550,15 +566,7 @@ qint64 QHttpNetworkReplyPrivate::readHeader(QAbstractSocket *socket)
// allocate inflate state
if (!inflateStrm)
inflateStrm = new z_stream;
- inflateStrm->zalloc = Z_NULL;
- inflateStrm->zfree = Z_NULL;
- inflateStrm->opaque = Z_NULL;
- inflateStrm->avail_in = 0;
- inflateStrm->next_in = Z_NULL;
- // "windowBits can also be greater than 15 for optional gzip decoding.
- // Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
- // http://www.zlib.net/manual.html
- int ret = inflateInit2(inflateStrm, MAX_WBITS+32);
+ int ret = initializeInflateStream();
if (ret != Z_OK)
return -1;
}
@@ -703,8 +711,28 @@ qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QByteDataBuff
}
#ifndef QT_NO_COMPRESS
+int QHttpNetworkReplyPrivate::initializeInflateStream()
+{
+ inflateStrm->zalloc = Z_NULL;
+ inflateStrm->zfree = Z_NULL;
+ inflateStrm->opaque = Z_NULL;
+ inflateStrm->avail_in = 0;
+ inflateStrm->next_in = Z_NULL;
+ // "windowBits can also be greater than 15 for optional gzip decoding.
+ // Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
+ // http://www.zlib.net/manual.html
+ int ret = inflateInit2(inflateStrm, MAX_WBITS+32);
+ Q_ASSERT(ret == Z_OK);
+ return ret;
+}
+
qint64 QHttpNetworkReplyPrivate::uncompressBodyData(QByteDataBuffer *in, QByteDataBuffer *out)
{
+ if (!inflateStrm) { // happens when called from the SPDY protocol handler
+ inflateStrm = new z_stream;
+ initializeInflateStream();
+ }
+
if (!inflateStrm)
return -1;