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/qhttpprotocolhandler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/network/access/qhttpprotocolhandler.cpp') diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index b486b75449..ab136af083 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -129,6 +129,15 @@ void QHttpProtocolHandler::_q_receiveReply() } else { replyPrivate->autoDecompress = false; } + if (m_connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) { + if (replyPrivate->statusCode == 101) { + QMetaObject::invokeMethod(m_channel, "_q_protocolSwitch", Qt::QueuedConnection); + return; + } + + // HTTP/2 is not supported? TODO - but can it be something else? + m_channel->requeueSpdyRequests(); + } if (replyPrivate->statusCode == 100) { replyPrivate->clearHttpLayerInformation(); replyPrivate->state = QHttpNetworkReplyPrivate::ReadingStatusState; -- cgit v1.2.3