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 <simon.hausmann@qt.io>
This commit is contained in:
Timur Pocheptsov 2016-08-15 08:44:54 +02:00 committed by Liang Qi
parent 12eacc3bab
commit bdc16cce79
4 changed files with 21 additions and 23 deletions

View File

@ -86,7 +86,7 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
, channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY || type == QHttpNetworkConnection::ConnectionTypeHTTP2) , channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY || type == QHttpNetworkConnection::ConnectionTypeHTTP2)
? 1 : defaultHttpChannelCount) ? 1 : defaultHttpChannelCount)
#else #else
, channelCount(defaultHttpChannelCount) , channelCount(type == QHttpNetworkConnection::ConnectionTypeHTTP2 ? 1 : defaultHttpChannelCount)
#endif // QT_NO_SSL #endif // QT_NO_SSL
#ifndef QT_NO_NETWORKPROXY #ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy) , networkProxy(QNetworkProxy::NoProxy)
@ -619,13 +619,11 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
break; break;
} }
} }
#ifndef QT_NO_SSL else { // SPDY, HTTP/2
else { // SPDY
if (!pair.second->d_func()->requestIsPrepared) if (!pair.second->d_func()->requestIsPrepared)
prepareRequest(pair); prepareRequest(pair);
channels[0].spdyRequestsToSend.insertMulti(request.priority(), pair); channels[0].spdyRequestsToSend.insertMulti(request.priority(), pair);
} }
#endif // QT_NO_SSL
// For Happy Eyeballs the networkLayerState is set to Unknown // For Happy Eyeballs the networkLayerState is set to Unknown
// untill we have started the first connection attempt. So no // untill we have started the first connection attempt. So no
@ -1013,9 +1011,9 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
} }
break; break;
} }
case QHttpNetworkConnection::ConnectionTypeSPDY: case QHttpNetworkConnection::ConnectionTypeHTTP2:
case QHttpNetworkConnection::ConnectionTypeHTTP2: { case QHttpNetworkConnection::ConnectionTypeSPDY: {
#ifndef QT_NO_SSL
if (channels[0].spdyRequestsToSend.isEmpty()) if (channels[0].spdyRequestsToSend.isEmpty())
return; return;
@ -1027,7 +1025,6 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState
&& !channels[0].pendingEncrypt) && !channels[0].pendingEncrypt)
channels[0].sendRequest(); channels[0].sendRequest();
#endif // QT_NO_SSL
break; break;
} }
} }

View File

@ -1039,6 +1039,19 @@ void QHttpNetworkConnectionChannel::_q_uploadDataReadyRead()
sendRequest(); sendRequest();
} }
void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error,
const char *message)
{
if (reply)
emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
QList<HttpMessagePair> 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 #ifndef QT_NO_SSL
void QHttpNetworkConnectionChannel::_q_encrypted() void QHttpNetworkConnectionChannel::_q_encrypted()
{ {
@ -1113,19 +1126,6 @@ void QHttpNetworkConnectionChannel::requeueSpdyRequests()
spdyRequestsToSend.clear(); spdyRequestsToSend.clear();
} }
void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error,
const char *message)
{
if (reply)
emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
QList<HttpMessagePair> 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<QSslError> &errors) void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
{ {
if (!socket) if (!socket)

View File

@ -133,9 +133,9 @@ public:
void ignoreSslErrors(const QList<QSslError> &errors); void ignoreSslErrors(const QList<QSslError> &errors);
void setSslConfiguration(const QSslConfiguration &config); void setSslConfiguration(const QSslConfiguration &config);
void requeueSpdyRequests(); // when we wanted SPDY but got HTTP void requeueSpdyRequests(); // when we wanted SPDY but got HTTP
#endif
// to emit the signal for all in-flight replies: // to emit the signal for all in-flight replies:
void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message); void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message);
#endif
#ifndef QT_NO_BEARERMANAGEMENT #ifndef QT_NO_BEARERMANAGEMENT
QSharedPointer<QNetworkSession> networkSession; QSharedPointer<QNetworkSession> networkSession;
#endif #endif

View File

@ -35,10 +35,11 @@
#ifndef QT_NO_SSL #ifndef QT_NO_SSL
#include <QtNetwork/qsslconfiguration.h> #include <QtNetwork/qsslconfiguration.h>
#include <QtNetwork/qsslsocket.h>
#include <QtNetwork/qsslkey.h> #include <QtNetwork/qsslkey.h>
#endif #endif
#include <QtNetwork/qabstractsocket.h> #include <QtNetwork/qtcpsocket.h>
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>