From b2c0f9713c1c39bc3214df49f0d2b44bcc84d790 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 12 Jan 2016 14:45:47 +0100 Subject: HTTP2 protocol handler Add HTTP2 support in QNAM - QHttp2ProtocolHandler + aux. classes. [ChangeLog][QtNetwork] Added support for HTTP/2 protocol Task-number: QTBUG-50956 Change-Id: I3a119cfbb1fb3118d9003225f5e54b46ae2829b6 Reviewed-by: Edward Welbourne --- src/network/access/qhttpnetworkconnectionchannel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp') diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 2f7be01078..791a7495c0 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -47,6 +47,7 @@ #ifndef QT_NO_HTTP +#include #include #include @@ -971,7 +972,8 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket } while (!connection->d_func()->highPriorityQueue.isEmpty() || !connection->d_func()->lowPriorityQueue.isEmpty()); #ifndef QT_NO_SSL - if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY || + connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) { QList spdyPairs = spdyRequestsToSend.values(); for (int a = 0; a < spdyPairs.count(); ++a) { // emit error for all replies @@ -1003,7 +1005,8 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth) { #ifndef QT_NO_SSL - if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY || + connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) { connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth); } else { // HTTP #endif // QT_NO_SSL @@ -1043,6 +1046,10 @@ void QHttpNetworkConnectionChannel::_q_encrypted() // no need to re-queue requests, if SPDY was enabled on the request it // has gone to the SPDY queue already break; + } else if (nextProtocol == QSslConfiguration::ALPNProtocolHTTP2) { + protocolHandler.reset(new QHttp2ProtocolHandler(this)); + connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeHTTP2); + break; } else { emitFinishedWithError(QNetworkReply::SslHandshakeFailedError, "detected unknown Next Protocol Negotiation protocol"); @@ -1066,7 +1073,8 @@ void QHttpNetworkConnectionChannel::_q_encrypted() state = QHttpNetworkConnectionChannel::IdleState; pendingEncrypt = false; - if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) { + if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY || + connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) { // we call setSpdyWasUsed(true) on the replies in the SPDY handler when the request is sent if (spdyRequestsToSend.count() > 0) // wait for data from the server first (e.g. initial window, max concurrent requests) -- cgit v1.2.3