49class QHttp2ProtocolHandler :
public QObject,
public QAbstractProtocolHandler
54 QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel);
56 QHttp2ProtocolHandler(
const QHttp2ProtocolHandler &rhs) =
delete;
57 QHttp2ProtocolHandler(QHttp2ProtocolHandler &&rhs) =
delete;
59 QHttp2ProtocolHandler &operator=(
const QHttp2ProtocolHandler &rhs) =
delete;
60 QHttp2ProtocolHandler &operator=(QHttp2ProtocolHandler &&rhs) =
delete;
62 Q_INVOKABLE
void handleConnectionClosure();
65 void _q_uploadDataDestroyed(QObject *uploadData);
68 using Stream = Http2::Stream;
70 void _q_readyRead() override;
71 Q_INVOKABLE
void _q_receiveReply() override;
72 Q_INVOKABLE
bool sendRequest() override;
73 bool tryRemoveReply(QHttpNetworkReply *reply) override;
75 bool sendSETTINGS_ACK();
76 bool sendHEADERS(QHttp2Stream *stream, QHttpNetworkRequest &request);
77 bool sendDATA(QHttp2Stream *stream, QHttpNetworkReply *reply);
79 bool acceptSetting(Http2::Settings identifier, quint32 newValue);
81 void handleAuthorization(QHttp2Stream *stream);
82 void handleHeadersReceived(
const HPack::HttpHeader &headers,
bool endStream);
83 void handleDataReceived(
const QByteArray &data,
bool endStream);
84 void finishStream(QHttp2Stream *stream,
85 Qt::ConnectionType connectionType = Qt::DirectConnection);
87 void handleGOAWAY(Http2::Http2Error errorCode, quint32 lastStreamID);
88 void finishStreamWithError(QHttp2Stream *stream, Http2::Http2Error errorCode);
90 void finishStreamWithError(QHttp2Stream *stream, QNetworkReply::NetworkError error,
91 const QString &message);
94 QHttp2Stream *createNewStream(
const HttpMessagePair &message,
bool uploadDone =
false);
95 void connectStream(
const HttpMessagePair &message, QHttp2Stream *stream);
96 quint32 popStreamToResume();
98 QHttp2Connection *h2Connection;
103 bool waitingForSettingsACK =
false;
105 inline static const quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize;
107 QHash<QObject *, QPointer<QHttp2Stream>> streamIDs;
108 using HttpMessagePair = std::pair<QHttpNetworkRequest, QHttpNetworkReply *>;
109 QHash<QHttp2Stream *, HttpMessagePair> requestReplyPairs;
111 void initReplyFromPushPromise(
const HttpMessagePair &message,
const QUrl &cacheKey);
113 void connectionError(Http2::Http2Error errorCode,
const QString &message);