Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qhttp2protocolhandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QHTTP2PROTOCOLHANDLER_P_H
6#define QHTTP2PROTOCOLHANDLER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the Network Access API. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qhttpnetworkconnectionchannel_p.h>
20#include <private/qabstractprotocolhandler_p.h>
21#include <private/qhttpnetworkrequest_p.h>
22
23#include <QtNetwork/qhttp2configuration.h>
24
25#include <private/qhttp2connection_p.h>
26#include <private/http2protocol_p.h>
27#include <private/http2streams_p.h>
28#include <private/http2frames_p.h>
29#include <private/hpacktable_p.h>
30#include <private/hpack_p.h>
31
32#include <QtCore/qnamespace.h>
33#include <QtCore/qbytearray.h>
34#include <QtCore/qobject.h>
35#include <QtCore/qflags.h>
36#include <QtCore/qhash.h>
37
38#include <vector>
39#include <limits>
40#include <memory>
41#include <deque>
42#include <set>
43
45
46QT_BEGIN_NAMESPACE
47
48class tst_Http2;
49
51{
53 friend class tst_Http2;
54
55public:
56 QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel);
57
60
63
65 bool isGoingAway() const noexcept;
66
67private slots:
69
70private:
71 using Stream = Http2::Stream;
72
74 Q_INVOKABLE void _q_receiveReply() override;
75 Q_INVOKABLE bool sendRequest() override;
76 bool tryRemoveReply(QHttpNetworkReply *reply) override;
77
78 bool sendSETTINGS_ACK();
79 bool sendHEADERS(QHttp2Stream *stream, QHttpNetworkRequest &request);
80 bool sendDATA(QHttp2Stream *stream, QHttpNetworkReply *reply);
81
82 bool acceptSetting(Http2::Settings identifier, quint32 newValue);
83
84 void handleAuthorization(QHttp2Stream *stream);
85 void handleHeadersReceived(const HPack::HttpHeader &headers, bool endStream);
86 void handleDataReceived(const QByteArray &data, bool endStream);
87 void finishStream(QHttp2Stream *stream,
88 Qt::ConnectionType connectionType = Qt::DirectConnection);
89 // Error code send by a peer (GOAWAY/RST_STREAM):
90 void handleGOAWAY(Http2::Http2Error errorCode, quint32 lastStreamID);
91 void finishStreamWithError(QHttp2Stream *stream, Http2::Http2Error errorCode);
92 // Locally encountered error:
93 void finishStreamWithError(QHttp2Stream *stream, QNetworkReply::NetworkError error,
94 const QString &message);
95
96 // Stream's lifecycle management:
97 QHttp2Stream *createNewStream(const HttpMessagePair &message, bool uploadDone = false);
98 void connectStream(const HttpMessagePair &message, QHttp2Stream *stream);
99 void clearStreamState(QHttp2Stream *stream);
100
101 QHttp2Connection *h2Connection;
102
103 // In the current implementation we send
104 // SETTINGS only once, immediately after
105 // the client's preface 24-byte message.
106 bool waitingForSettingsACK = false;
107
108 inline static const quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize;
109
111 QHash<QHttp2Stream *, HttpMessagePair> requestReplyPairs;
112
113 void initReplyFromPushPromise(const HttpMessagePair &message, const QUrl &cacheKey);
114 // Errors:
115 void connectionError(Http2::Http2Error errorCode, const QString &message);
116 void closeSession();
117};
118
119QT_END_NAMESPACE
120
121#endif
The QAuthenticator class provides an authentication object.
bool isGoingAway() const noexcept
QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel)
Q_INVOKABLE void handleConnectionClosure()
Q_INVOKABLE void _q_receiveReply() override
QHttp2ProtocolHandler & operator=(const QHttp2ProtocolHandler &rhs)=delete
QHttp2ProtocolHandler & operator=(QHttp2ProtocolHandler &&rhs)=delete
Q_INVOKABLE bool sendRequest() override
bool tryRemoveReply(QHttpNetworkReply *reply) override
QHttp2ProtocolHandler(QHttp2ProtocolHandler &&rhs)=delete
QHttp2ProtocolHandler(const QHttp2ProtocolHandler &rhs)=delete
qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const
bool shouldEmitChannelError(QIODevice *socket)
void createAuthorization(QIODevice *socket, QHttpNetworkRequest &request)
void emitReplyError(QIODevice *socket, QHttpNetworkReply *reply, QNetworkReply::NetworkError errorCode)
QTcpKeepAliveConfiguration tcpKeepAliveConfiguration
QUrl parseRedirectResponse(QIODevice *socket, QHttpNetworkReply *reply)
QHttpNetworkRequest predictNextRequest() const
void prepareRequest(HttpMessagePair &request)
NetworkLayerPreferenceState networkLayerState
void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy)
std::shared_ptr< QSslContext > sslContext
void networkLayerDetected(QAbstractSocket::NetworkLayerProtocol protocol)
void requeueRequest(const HttpMessagePair &pair)
QList< HttpMessagePair > lowPriorityQueue
void removeReply(QHttpNetworkReply *reply)
void _q_hostLookupFinished(const QHostInfo &info)
QHttpNetworkReply * predictNextRequestsReply() const
QList< HttpMessagePair > highPriorityQueue
void updateChannel(int i, const HttpMessagePair &messagePair)
bool handleAuthenticateChallenge(QIODevice *socket, QHttpNetworkReply *reply, bool isProxy, bool &resend)
QHttpNetworkReply * queueRequest(const QHttpNetworkRequest &request)
QHttpNetworkConnectionChannel *const channels
void readMoreLater(QHttpNetworkReply *reply)
int indexOf(QIODevice *socket) const
qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const
static ParseRedirectResult parseRedirectResponse(QHttpNetworkReply *reply)
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
The QNetworkProxy class provides a network layer proxy.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2620
QT_REQUIRE_CONFIG(http)
std::pair< QHttpNetworkRequest, QHttpNetworkReply * > HttpMessagePair