Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qhttpnetworkconnectionchannel_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
4#ifndef QHTTPNETWORKCONNECTIONCHANNEL_H
5#define QHTTPNETWORKCONNECTIONCHANNEL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of the Network Access API. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtNetwork/private/qtnetworkglobal_p.h>
19#include <QtNetwork/qnetworkrequest.h>
20#include <QtNetwork/qnetworkreply.h>
21#include <QtNetwork/qabstractsocket.h>
22
23#include <private/qobject_p.h>
24#include <qauthenticator.h>
25#include <qnetworkproxy.h>
26#include <qbuffer.h>
27
28#include <private/qhttpnetworkheader_p.h>
29#include <private/qhttpnetworkrequest_p.h>
30#include <private/qhttpnetworkreply_p.h>
31
32#include <private/qhttpnetworkconnection_p.h>
33#include <private/qabstractprotocolhandler_p.h>
34
35#ifndef QT_NO_SSL
36# include <QtNetwork/qsslsocket.h>
37# include <QtNetwork/qsslerror.h>
38# include <QtNetwork/qsslconfiguration.h>
39#else
40# include <QtNetwork/qtcpsocket.h>
41#endif
42
43#include <QtCore/qscopedpointer.h>
44
45#include <memory>
46
48
50
53class QByteArray;
54
55#ifndef HttpMessagePair
57#endif
58
61public:
62 // TODO: Refactor this to add an EncryptingState (and remove pendingEncrypt).
63 // Also add an Unconnected state so IdleState does not have double meaning.
65 IdleState = 0, // ready to send request
66 ConnectingState = 1, // connecting to host
67 WritingState = 2, // writing the data
68 WaitingState = 4, // waiting for reply
69 ReadingState = 8, // reading the reply
72 };
74 bool ssl;
77 QHttpNetworkRequest request; // current request, only used for HTTP
78 QHttpNetworkReply *reply; // current reply for this request, only used for HTTP
82 int lastStatus; // last status received on this channel
83 bool pendingEncrypt; // for https (send after encrypted)
84 int reconnectAttempts; // maximum 2 reconnection attempts
89 std::unique_ptr<QAbstractProtocolHandler> protocolHandler;
91 bool switchedToHttp2 = false;
92#ifndef QT_NO_SSL
96 void ignoreSslErrors();
97 void ignoreSslErrors(const QList<QSslError> &errors);
99 void requeueHttp2Requests(); // when we wanted HTTP/2 but got HTTP/1.1
100#endif
101 // to emit the signal for all in-flight replies:
103
104 // HTTP pipelining -> http://en.wikipedia.org/wiki/Http_pipelining
106 PipeliningSupportUnknown, // default for a new connection
107 PipeliningProbablySupported, // after having received a server response that indicates support
108 PipeliningNotSupported // currently not used
109 };
112 QByteArray pipeline; // temporary buffer that gets sent to socket in pipelineFlush
113 void pipelineInto(HttpMessagePair &pair);
114 void pipelineFlush();
117
119
121
124
125#ifndef QT_NO_NETWORKPROXY
127 void setProxy(const QNetworkProxy &networkProxy);
128#endif
129
130 void init();
131 void close();
132 void abort();
133
134 bool sendRequest();
135 void sendRequestDelayed();
136
137 bool ensureConnection();
138
139 void allDone(); // reply header + body have been read
140 void handleStatus(); // called from allDone()
141
142 bool resetUploadData(); // return true if resetting worked or there is no upload data
143
144 void handleUnexpectedEOF();
147
148 bool isSocketBusy() const;
149 bool isSocketWriting() const;
150 bool isSocketWaiting() const;
151 bool isSocketReading() const;
152
153 protected slots:
154 void _q_receiveReply();
155 void _q_bytesWritten(qint64 bytes); // proceed sending
156 void _q_readyRead(); // pending data to read
157 void _q_disconnected(); // disconnected from host
158 void _q_connected(); // start sending request
159 void _q_error(QAbstractSocket::SocketError); // error from socket
160#ifndef QT_NO_NETWORKPROXY
161 void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); // from transparent proxy
162#endif
163
165
166#ifndef QT_NO_SSL
167 void _q_encrypted(); // start sending request (https)
168 void _q_sslErrors(const QList<QSslError> &errors); // ssl errors from the socket
170 void _q_encryptedBytesWritten(qint64 bytes); // proceed sending
171#endif
172
174};
175
177
178#endif
The QAbstractSocket class provides the base functionality common to all socket types.
SocketError
This enum describes the socket errors that can occur.
The QAuthenticator class provides an authentication object.
\inmodule QtCore
Definition qbytearray.h:57
std::unique_ptr< QAbstractProtocolHandler > protocolHandler
QScopedPointer< QSslConfiguration > sslConfiguration
void setProxy(const QNetworkProxy &networkProxy)
void _q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *)
void setSslConfiguration(const QSslConfiguration &config)
QAbstractSocket::NetworkLayerProtocol networkLayerPreference
void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message)
QPointer< QHttpNetworkConnection > connection
QMultiMap< int, HttpMessagePair > h2RequestsToSend
void _q_sslErrors(const QList< QSslError > &errors)
void setConnection(QHttpNetworkConnection *c)
void _q_error(QAbstractSocket::SocketError)
void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
Definition qlist.h:74
The QNetworkProxy class provides a network layer proxy.
NetworkError
Indicates all possible error conditions found during the processing of the request.
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore
The QSslConfiguration class holds the configuration and state of an SSL connection.
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
DBusConnection const char DBusError * error
EGLConfig config
QPair< QHttpNetworkRequest, QHttpNetworkReply * > HttpMessagePair
GLuint GLsizei const GLchar * message
const GLubyte * c
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define slots
long long qint64
Definition qtypes.h:55