From bdc16cce7972cdd0bd02b58077a8dd465036632c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 15 Aug 2016 08:44:54 +0200 Subject: HTTP/2 - fix QT_NO_SSL build Recently enabled cleartext fails to build with QT_NO_SSL - fix test and QNAM. Change-Id: I467edab8e4eb5113715ad2d3b3022e0d8c027de8 Reviewed-by: Simon Hausmann --- src/network/access/qhttpnetworkconnection.cpp | 13 +++++------ .../access/qhttpnetworkconnectionchannel.cpp | 26 +++++++++++----------- .../access/qhttpnetworkconnectionchannel_p.h | 2 +- 3 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 09cea8e769..74fc23957c 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -86,7 +86,7 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host , channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY || type == QHttpNetworkConnection::ConnectionTypeHTTP2) ? 1 : defaultHttpChannelCount) #else -, channelCount(defaultHttpChannelCount) +, channelCount(type == QHttpNetworkConnection::ConnectionTypeHTTP2 ? 1 : defaultHttpChannelCount) #endif // QT_NO_SSL #ifndef QT_NO_NETWORKPROXY , networkProxy(QNetworkProxy::NoProxy) @@ -619,13 +619,11 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor break; } } -#ifndef QT_NO_SSL - else { // SPDY + else { // SPDY, HTTP/2 if (!pair.second->d_func()->requestIsPrepared) prepareRequest(pair); channels[0].spdyRequestsToSend.insertMulti(request.priority(), pair); } -#endif // QT_NO_SSL // For Happy Eyeballs the networkLayerState is set to Unknown // untill we have started the first connection attempt. So no @@ -1013,9 +1011,9 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() } break; } - case QHttpNetworkConnection::ConnectionTypeSPDY: - case QHttpNetworkConnection::ConnectionTypeHTTP2: { -#ifndef QT_NO_SSL + case QHttpNetworkConnection::ConnectionTypeHTTP2: + case QHttpNetworkConnection::ConnectionTypeSPDY: { + if (channels[0].spdyRequestsToSend.isEmpty()) return; @@ -1027,7 +1025,6 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest() if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState && !channels[0].pendingEncrypt) channels[0].sendRequest(); -#endif // QT_NO_SSL break; } } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 3317b9e5b9..ee155bdbed 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1039,6 +1039,19 @@ void QHttpNetworkConnectionChannel::_q_uploadDataReadyRead() sendRequest(); } +void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error, + const char *message) +{ + if (reply) + emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); + QList spdyPairs = spdyRequestsToSend.values(); + for (int a = 0; a < spdyPairs.count(); ++a) { + QHttpNetworkReply *currentReply = spdyPairs.at(a).second; + Q_ASSERT(currentReply); + emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); + } +} + #ifndef QT_NO_SSL void QHttpNetworkConnectionChannel::_q_encrypted() { @@ -1113,19 +1126,6 @@ void QHttpNetworkConnectionChannel::requeueSpdyRequests() spdyRequestsToSend.clear(); } -void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error, - const char *message) -{ - if (reply) - emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); - QList spdyPairs = spdyRequestsToSend.values(); - for (int a = 0; a < spdyPairs.count(); ++a) { - QHttpNetworkReply *currentReply = spdyPairs.at(a).second; - Q_ASSERT(currentReply); - emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message)); - } -} - void QHttpNetworkConnectionChannel::_q_sslErrors(const QList &errors) { if (!socket) diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 48f10d6286..61aea9d35d 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -133,9 +133,9 @@ public: void ignoreSslErrors(const QList &errors); void setSslConfiguration(const QSslConfiguration &config); void requeueSpdyRequests(); // when we wanted SPDY but got HTTP +#endif // to emit the signal for all in-flight replies: void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message); -#endif #ifndef QT_NO_BEARERMANAGEMENT QSharedPointer networkSession; #endif -- cgit v1.2.3