diff options
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 2cf44521eb..937686920c 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -40,7 +40,7 @@ #include "qhttpnetworkconnection_p.h" #include "qhttp2protocolhandler_p.h" -#if !defined(QT_NO_HTTP) +#if !defined(QT_NO_HTTP) && !defined(QT_NO_SSL) #include "http2/bitstreams_p.h" @@ -54,7 +54,6 @@ #include <QtCore/qurl.h> #include <algorithm> -#include <utility> #include <vector> QT_BEGIN_NAMESPACE @@ -134,28 +133,6 @@ QHttp2ProtocolHandler::QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *chan continuedFrames.reserve(20); } -QHttp2ProtocolHandler::QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel, - const HttpMessagePair &message) - : QAbstractProtocolHandler(channel), - prefaceSent(false), - waitingForSettingsACK(false), - decoder(HPack::FieldLookupTable::DefaultSize), - encoder(HPack::FieldLookupTable::DefaultSize, true) -{ - // That's a protocol upgrade scenario - 3.2. - // - // We still have to send settings and the preface - // (though SETTINGS was a part of the first HTTP/1.1 - // request "HTTP2-Settings" field). - // - // We pass 'false' for upload data, this was done by HTTP/1.1 protocol - // handler for us while sending the first request. - const quint32 initialStreamID = createNewStream(message, false); - Q_ASSERT(initialStreamID == 1); - Stream &stream = activeStreams[initialStreamID]; - stream.state = Stream::halfClosedLocal; -} - void QHttp2ProtocolHandler::_q_uploadDataReadyRead() { auto data = qobject_cast<QNonContiguousByteDevice *>(sender()); @@ -270,7 +247,7 @@ bool QHttp2ProtocolHandler::sendRequest() auto it = requests.begin(); m_channel->state = QHttpNetworkConnectionChannel::WritingState; for (quint32 i = 0; i < streamsToUse; ++i) { - const qint32 newStreamID = createNewStream(*it, true /* upload data */); + const qint32 newStreamID = createNewStream(*it); if (!newStreamID) { // TODO: actually we have to open a new connection. qCCritical(QT_HTTP2, "sendRequest: out of stream IDs"); @@ -301,6 +278,7 @@ bool QHttp2ProtocolHandler::sendRequest() return true; } + bool QHttp2ProtocolHandler::sendClientPreface() { // 3.5 HTTP/2 Connection Preface @@ -315,8 +293,12 @@ bool QHttp2ProtocolHandler::sendClientPreface() return false; // 6.5 SETTINGS - outboundFrame = Http2::qt_default_SETTINGS_frame(); - Q_ASSERT(outboundFrame.payloadSize()); + outboundFrame.start(FrameType::SETTINGS, FrameFlag::EMPTY, Http2::connectionStreamID); + // MAX frame size (16 kb), disable PUSH + outboundFrame.append(Settings::MAX_FRAME_SIZE_ID); + outboundFrame.append(quint32(Http2::maxFrameSize)); + outboundFrame.append(Settings::ENABLE_PUSH_ID); + outboundFrame.append(quint32(0)); if (!outboundFrame.write(*m_socket)) return false; @@ -1040,8 +1022,7 @@ void QHttp2ProtocolHandler::finishStreamWithError(Stream &stream, QNetworkReply: emit httpReply->finishedWithError(error, message); } -quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, - bool uploadData) +quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message) { const qint32 newStreamID = allocateStreamID(); if (!newStreamID) @@ -1062,12 +1043,10 @@ quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message, streamInitialSendWindowSize, streamInitialRecvWindowSize); - if (uploadData) { - if (auto src = newStream.data()) { - connect(src, SIGNAL(readyRead()), this, - SLOT(_q_uploadDataReadyRead()), Qt::QueuedConnection); - src->setProperty("HTTP2StreamID", newStreamID); - } + if (auto src = newStream.data()) { + connect(src, SIGNAL(readyRead()), this, + SLOT(_q_uploadDataReadyRead()), Qt::QueuedConnection); + src->setProperty("HTTP2StreamID", newStreamID); } activeStreams.insert(newStreamID, newStream); @@ -1235,4 +1214,4 @@ void QHttp2ProtocolHandler::closeSession() QT_END_NAMESPACE -#endif // !defined(QT_NO_HTTP) +#endif // !defined(QT_NO_HTTP) && !defined(QT_NO_SSL) |