summaryrefslogtreecommitdiffstats
path: root/src/network/access/http2/http2streams_p.h
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-10-10 15:29:26 +0200
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-10-21 14:27:06 +0000
commit512934f7e70592ed06a790fcb46dde1e435b488e (patch)
treef5fa91f8ce36289976e389ded3c155c45ac2ebb1 /src/network/access/http2/http2streams_p.h
parent016b5bc949b6dfb2f76db2e8b40a40e7eaee6828 (diff)
HTTP/2 - fix the handling of PUSH_PROMISE
HTTP/2 allows a server to pre-emptively send (or "push") responses (along with corresponding "promised" requests) to a client in association with a previous client-initiated request. This can be useful when the server knows the client will need to have those responses available in order to fully process the response to the original request. Server push is semantically equivalent to a server responding to a request; however, in this case, that request is also sent by the server, as a PUSH_PROMISE frame. The PUSH_PROMISE frame includes a header block that contains a complete set of request header fields that the server attributes to the request. After sending the PUSH_PROMISE frame, the server can begin delivering the pushed response as a response on a server-initiated stream that uses the promised stream identifier. This patch: - fixes the HPACK decompression of PUSH_PROMISE frames; - allows a user to enable PUSH_PROMISE; - processes and caches pushed data for promised streams; - updates auto-test - emulates a simple PUSH_PROMISE scenario. Change-Id: Ic4850863a5e3895320baac3871a723fc091b4aca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/access/http2/http2streams_p.h')
-rw-r--r--src/network/access/http2/http2streams_p.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/network/access/http2/http2streams_p.h b/src/network/access/http2/http2streams_p.h
index 8a825a5457..8465486ae8 100644
--- a/src/network/access/http2/http2streams_p.h
+++ b/src/network/access/http2/http2streams_p.h
@@ -51,10 +51,16 @@
// We mean it.
//
+#include "http2frames_p.h"
+#include "hpack_p.h"
+
#include <private/qhttpnetworkconnectionchannel_p.h>
#include <private/qhttpnetworkrequest_p.h>
#include <QtCore/qglobal.h>
+#include <QtCore/qstring.h>
+
+#include <vector>
QT_BEGIN_NAMESPACE
@@ -70,12 +76,16 @@ struct Q_AUTOTEST_EXPORT Stream
open,
halfClosedLocal,
halfClosedRemote,
+ remoteReserved,
closed
};
Stream();
+ // That's a ctor for a client-initiated stream:
Stream(const HttpMessagePair &message, quint32 streamID, qint32 sendSize,
qint32 recvSize);
+ // That's a reserved stream, created by PUSH_PROMISE from a server:
+ Stream(const QString &key, quint32 streamID, qint32 recvSize);
QHttpNetworkReply *reply() const;
const QHttpNetworkRequest &request() const;
@@ -92,9 +102,22 @@ struct Q_AUTOTEST_EXPORT Stream
qint32 recvWindow = 65535;
StreamState state = idle;
+ QString key; // for PUSH_PROMISE
+};
+
+struct PushPromise
+{
+ quint32 reservedID = 0;
+ // PUSH_PROMISE has its own HEADERS,
+ // usually similar to what request has:
+ HPack::HttpHeader pushHeader;
+ // Response has its own (normal) HEADERS:
+ HPack::HttpHeader responseHeader;
+ // DATA frames on a promised stream:
+ std::vector<Frame> dataFrames;
};
-}
+} // namespace Http2
QT_END_NAMESPACE