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
66private slots:
68
69private:
70 using Stream = Http2::Stream;
71
73 Q_INVOKABLE void _q_receiveReply() override;
74 Q_INVOKABLE bool sendRequest() override;
75 bool tryRemoveReply(QHttpNetworkReply *reply) override;
76
77 bool sendSETTINGS_ACK();
78 bool sendHEADERS(QHttp2Stream *stream, QHttpNetworkRequest &request);
79 bool sendDATA(QHttp2Stream *stream, QHttpNetworkReply *reply);
80
81 bool acceptSetting(Http2::Settings identifier, quint32 newValue);
82
83 void handleAuthorization(QHttp2Stream *stream);
84 void handleHeadersReceived(const HPack::HttpHeader &headers, bool endStream);
85 void handleDataReceived(const QByteArray &data, bool endStream);
86 void finishStream(QHttp2Stream *stream,
87 Qt::ConnectionType connectionType = Qt::DirectConnection);
88 // Error code send by a peer (GOAWAY/RST_STREAM):
89 void handleGOAWAY(Http2::Http2Error errorCode, quint32 lastStreamID);
90 void finishStreamWithError(QHttp2Stream *stream, Http2::Http2Error errorCode);
91 // Locally encountered error:
92 void finishStreamWithError(QHttp2Stream *stream, QNetworkReply::NetworkError error,
93 const QString &message);
94
95 // Stream's lifecycle management:
96 QHttp2Stream *createNewStream(const HttpMessagePair &message, bool uploadDone = false);
97 void connectStream(const HttpMessagePair &message, QHttp2Stream *stream);
98 void clearStreamState(QHttp2Stream *stream);
99
100 QHttp2Connection *h2Connection;
101
102 // In the current implementation we send
103 // SETTINGS only once, immediately after
104 // the client's preface 24-byte message.
105 bool waitingForSettingsACK = false;
106
107 inline static const quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize;
108
110 QHash<QHttp2Stream *, HttpMessagePair> requestReplyPairs;
111
112 void initReplyFromPushPromise(const HttpMessagePair &message, const QUrl &cacheKey);
113 // Errors:
114 void connectionError(Http2::Http2Error errorCode, const QString &message);
115 void closeSession();
116};
117
118QT_END_NAMESPACE
119
120#endif
The QAuthenticator class provides an authentication object.
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:2598
QT_REQUIRE_CONFIG(http)
std::pair< QHttpNetworkRequest, QHttpNetworkReply * > HttpMessagePair