From 12d71f4ea20415ff2274e1e90f9e4d5a8b935d7f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 14 Jul 2016 16:49:16 +0200 Subject: Implement protocol upgrade for HTTP/2 enabled requests Without ALPN/NPN (== without OpenSSL) we can negotiate HTTP/2 using the protocol upgrade procedure as described by RFC7540. Since there is no TLS handshake, after our http channel was connected we first send an 'augmented' HTTP/1.1 request - its header contains additional 'HTTP2-Settings' and 'Upgrade' (to 'h2c') fields. If we receive reponse 101 (switch protocol) we re-create a protocol handler and switch to HTTP/2. Task-number: QTBUG-50955 Change-Id: I36e9985e06ba76edaf7fdb22bb43770f8d593c61 Reviewed-by: Edward Welbourne --- src/network/access/qhttp2protocolhandler_p.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/network/access/qhttp2protocolhandler_p.h') diff --git a/src/network/access/qhttp2protocolhandler_p.h b/src/network/access/qhttp2protocolhandler_p.h index b146e37dd3..e41b1360bf 100644 --- a/src/network/access/qhttp2protocolhandler_p.h +++ b/src/network/access/qhttp2protocolhandler_p.h @@ -55,7 +55,7 @@ #include #include -#if !defined(QT_NO_HTTP) && !defined(QT_NO_SSL) +#if !defined(QT_NO_HTTP) #include "http2/http2protocol_p.h" #include "http2/http2streams_p.h" @@ -81,7 +81,15 @@ class QHttp2ProtocolHandler : public QObject, public QAbstractProtocolHandler Q_OBJECT public: + // "TLS + ALPN/NPN" case: QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel); + // HTTP2 without TLS - the first request was sent as an HTTP/1.1 request + // with Upgrade:h2c header. That serves as an implicit HTTP/2 request + // on a stream with ID 1 (it will be created in this ctor in a + // 'half-closed-local' state); reply, if server supports HTTP/2, + // will be HTTP/2 frame(s): + QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel, + const HttpMessagePair &message); QHttp2ProtocolHandler(const QHttp2ProtocolHandler &rhs) = delete; QHttp2ProtocolHandler(QHttp2ProtocolHandler &&rhs) = delete; @@ -133,7 +141,7 @@ private: const QString &message); // Stream's lifecycle management: - quint32 createNewStream(const HttpMessagePair &message); + quint32 createNewStream(const HttpMessagePair &message, bool uploadData); void addToSuspended(Stream &stream); void markAsReset(quint32 streamID); quint32 popStreamToResume(); @@ -202,6 +210,6 @@ private: QT_END_NAMESPACE -#endif // !defined(QT_NO_HTTP) && !defined(QT_NO_SSL) +#endif // !defined(QT_NO_HTTP) #endif -- cgit v1.2.3