8#include "private/qnoncontiguousbytedevice_p.h"
13#include <private/qhttp2protocolhandler_p.h>
14#include <private/qhttpprotocolhandler_p.h>
15#include <private/http2protocol_p.h>
18# include <private/qsslsocket_p.h>
19# include <QtNetwork/qsslkey.h>
20# include <QtNetwork/qsslcipher.h>
23#include "private/qnetconmonitor_p.h"
53 , isInitialized(
false)
58 , resendCurrent(
false)
60 , pendingEncrypt(
false)
62 , authenticationCredentialsSent(
false)
63 , proxyCredentialsSent(
false)
66 , ignoreAllSslErrors(
false)
68 , pipeliningSupported(PipeliningSupportUnknown)
86#ifndef QT_NO_NETWORKPROXY
110 qRegisterMetaType<QAbstractSocket::SocketError>();
119#ifndef QT_NO_NETWORKPROXY
158#ifndef QT_NO_NETWORKPROXY
259 reply->d_func()->clear();
261 reply->d_func()->connectionChannel =
this;
304 priv->hasFailed =
false;
307 priv->hasFailed =
false;
326 if (potentialReply) {
332#ifndef QT_NO_NETWORKPROXY
350 value =
connection->d_func()->predictNextRequest().headerField(
"user-agent");
355 if (!
value.isEmpty()) {
390#ifndef QT_NO_NETWORKPROXY
398#ifndef QT_NO_NETWORKPROXY
427 qWarning(
"QHttpNetworkConnectionChannel::allDone() called without reply. Please report at http://bugreports.qt.io/");
448 auto deleter = std::make_unique<ProtocolHandlerDeleter>(oldHandler);
452 deleter->deleteLater();
473 bool emitFinished =
reply->d_func()->shouldEmitSignals();
474 bool connectionCloseEnabled =
reply->d_func()->isConnectionCloseEnabled();
483 if (
reply && emitFinished)
517 reply = messagePair.second;
538 if (connectionCloseEnabled)
541 if (qobject_cast<QHttpNetworkConnection*>(
connection))
555 && (!
reply->d_func()->isConnectionCloseEnabled())
561 && (!serverHeaderField.
contains(
"Microsoft-IIS/5."))
562 && (!serverHeaderField.
contains(
"Netscape-Enterprise/3."))
564 && (!serverHeaderField.
contains(
"WebLogic"))
583 if (qobject_cast<QHttpNetworkConnection*>(
connection))
595 switch (statusCode) {
612 }
else if (qobject_cast<QHttpNetworkConnection *>(
connection)) {
624 reply->d_func()->eraseData();
650 if (qobject_cast<QHttpNetworkConnection*>(
connection))
667 if (!uploadByteDevice->reset()) {
676#ifndef QT_NO_NETWORKPROXY
683 proxy = networkProxy;
726 reply->d_func()->clear();
728 reply->d_func()->connectionChannel =
this;
730 reply->d_func()->pipeliningUsed =
true;
732#ifndef QT_NO_NETWORKPROXY
765 if (qobject_cast<QHttpNetworkConnection*>(
connection))
774 if (qobject_cast<QHttpNetworkConnection*>(
connection))
846 if (
connection->d_func()->delayedConnectionTimer.isActive())
847 connection->d_func()->delayedConnectionTimer.stop();
888 auto connectionPrivate =
connection->d_func();
889 if (!connectionPrivate->connectionMonitor.isMonitoring()) {
893 connectionPrivate->connectionMonitor.startMonitoring();
919 if (tryProtocolUpgrade) {
929 if (tryProtocolUpgrade) {
946 switch (socketError) {
952#ifndef QT_NO_NETWORKPROXY
993 if (!
reply->d_func()->expectContent()) {
1086 reply->d_func()->httpErrorCode = errorCode;
1092 }
while (!
connection->d_func()->highPriorityQueue.isEmpty()
1093 || !
connection->d_func()->lowPriorityQueue.isEmpty());
1098 for (
int a = 0;
a < h2Pairs.
size(); ++
a) {
1101 currentReply->d_func()->
errorString = errorString;
1102 currentReply->d_func()->httpErrorCode = errorCode;
1126#ifndef QT_NO_NETWORKPROXY
1133 connection->d_func()->emitProxyAuthenticationRequired(
this,
proxy, auth);
1139 connection->d_func()->emitProxyAuthenticationRequired(
this,
proxy, auth);
1156 for (
int a = 0;
a < h2Pairs.
size(); ++
a) {
1185 "detected unknown Next Protocol Negotiation protocol");
1196 const int nProtocols = protocols.
size();
1202 if (nProtocols > protocols.
size()) {
1204 const int channelCount =
connection->d_func()->channelCount;
1205 for (
int i = 0;
i < channelCount; ++
i)
1222 "detected unknown Next Protocol Negotiation protocol");
1241 const auto &pair = h2Pairs.
first();
1242 emit pair.second->encrypted();
1263 for (
int a = 0;
a < h2Pairs.
size(); ++
a)
1285 for (
int a = 0;
a < h2Pairs.
size(); ++
a) {
1308 for (
int a = 0;
a < h2Pairs.
size(); ++
a) {
1339#include "moc_qhttpnetworkconnectionchannel_p.cpp"
The QAbstractSocket class provides the base functionality common to all socket types.
SocketState
This enum describes the different states in which a socket can be.
virtual void setReadBufferSize(qint64 size)
Sets the size of QAbstractSocket's internal read buffer to be size bytes.
static constexpr auto IPv4Protocol
void abort()
Aborts the current connection and resets the socket.
virtual void setSocketOption(QAbstractSocket::SocketOption option, const QVariant &value)
qint64 bytesAvailable() const override
Returns the number of incoming bytes that are waiting to be read.
QHostAddress localAddress() const
Returns the host address of the local socket if available; otherwise returns QHostAddress::Null.
QNetworkProxy proxy() const
void setProxy(const QNetworkProxy &networkProxy)
static constexpr auto AnyIPProtocol
void close() override
Closes the I/O device for the socket and calls disconnectFromHost() to close the socket's connection.
SocketState state() const
Returns the state of the socket.
SocketError
This enum describes the socket errors that can occur.
@ ProxyConnectionClosedError
@ ProxyConnectionRefusedError
@ ProxyConnectionTimeoutError
@ SslHandshakeFailedError
@ ProxyAuthenticationRequiredError
static constexpr auto IPv6Protocol
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol)
Attempts to make a connection to hostName on the given port.
QHostAddress peerAddress() const
Returns the address of the connected peer if the socket is in ConnectedState; otherwise returns QHost...
static QAuthenticatorPrivate * getPrivate(QAuthenticator &auth)
The QAuthenticator class provides an authentication object.
bool startsWith(QByteArrayView bv) const
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void clear()
Clears the contents of the byte array and makes it null.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
Q_INVOKABLE void handleConnectionClosure()
bool isSocketReading() const
std::unique_ptr< QAbstractProtocolHandler > protocolHandler
QScopedPointer< QSslConfiguration > sslConfiguration
QAuthenticator proxyAuthenticator
bool isSocketWaiting() const
void setProxy(const QNetworkProxy &networkProxy)
void _q_preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *)
void requeueCurrentlyPipelinedRequests()
void setSslConfiguration(const QSslConfiguration &config)
QHttpNetworkConnectionChannel()
friend class QHttpProtocolHandler
void handleUnexpectedEOF()
void sendRequestDelayed()
void _q_bytesWritten(qint64 bytes)
QAbstractSocket::NetworkLayerProtocol networkLayerPreference
bool proxyCredentialsSent
void closeAndResendCurrentRequest()
void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message)
void pipelineInto(HttpMessagePair &pair)
void resendCurrentRequest()
void _q_uploadDataReadyRead()
void detectPipeliningSupport()
bool isSocketBusy() const
void _q_encryptedBytesWritten(qint64 bytes)
PipeliningSupport pipeliningSupported
QPointer< QHttpNetworkConnection > connection
QHttpNetworkReply * reply
bool isSocketWriting() const
QHttpNetworkRequest request
QMultiMap< int, HttpMessagePair > h2RequestsToSend
void _q_sslErrors(const QList< QSslError > &errors)
void setConnection(QHttpNetworkConnection *c)
@ PipeliningProbablySupported
@ PipeliningSupportUnknown
void requeueHttp2Requests()
QList< QSslError > ignoreSslErrorsList
bool authenticationCredentialsSent
QList< HttpMessagePair > alreadyPipelinedRequests
void _q_error(QAbstractSocket::SocketError)
void _q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
QAuthenticator authenticator
QHttp2Configuration http2Parameters() const
ConnectionType connectionType()
QNetworkProxy cacheProxy() const
QHttpNetworkConnectionChannel * channels() const
void setConnectionType(ConnectionType type)
QString peerVerifyName() const
QNetworkProxy transparentProxy() const
std::shared_ptr< QSslContext > sslContext()
@ ConnectionTypeHTTP2Direct
void setSslContext(std::shared_ptr< QSslContext > context)
QHttpNetworkConnection * connection()
QString errorString() const
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator)
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail=QString())
void setHttp2WasUsed(bool h2Used)
void setReadBufferSize(qint64 size)
void setDownstreamLimited(bool t)
int minorVersion() const override
qint64 contentLength() const override
void setRedirectUrl(const QUrl &url)
void sslErrors(const QList< QSslError > &errors)
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const override
int majorVersion() const override
static QByteArray header(const QHttpNetworkRequest &request, bool throughProxy)
QUrl url() const override
QNonContiguousByteDevice * uploadByteDevice() const
QByteArray headerField(const QByteArray &name, const QByteArray &defaultValue=QByteArray()) const override
bool isOpen() const
Returns true if the device is open; otherwise returns false.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype removeAll(const AT &t)
void append(parameter_type t)
QList< T > values() const
The QNetworkProxy class provides a network layer proxy.
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
NetworkError
Indicates all possible error conditions found during the processing of the request.
@ ProxyConnectionRefusedError
@ ProxyConnectionClosedError
@ SslHandshakeFailedError
@ ProxyAuthenticationRequiredError
@ AuthenticationRequiredError
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
The QSslConfiguration class holds the configuration and state of an SSL connection.
QList< QByteArray > allowedNextProtocols() const
bool isNull() const
Returns true if this is a null QSslConfiguration object.
static const char ALPNProtocolHTTP2[]
QByteArray nextNegotiatedProtocol() const
void setAllowedNextProtocols(const QList< QByteArray > &protocols)
static const char NextProtocolHttp1_1[]
@ NextProtocolNegotiationNone
@ NextProtocolNegotiationUnsupported
@ NextProtocolNegotiationNegotiated
NextProtocolNegotiationStatus nextProtocolNegotiationStatus() const
The QSslPreSharedKeyAuthenticator class provides authentication data for pre shared keys (PSK) cipher...
static std::shared_ptr< QSslContext > sslContext(QSslSocket *socket)
static void checkSettingSslContext(QSslSocket *, std::shared_ptr< QSslContext >)
The QSslSocket class provides an SSL encrypted socket for both clients and servers.
QSslConfiguration sslConfiguration() const
void setSslConfiguration(const QSslConfiguration &config)
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode=ReadWrite, NetworkLayerProtocol protocol=AnyIPProtocol)
Starts an encrypted connection to the device hostName on port, using mode as the \l OpenMode.
void setPeerVerifyName(const QString &hostName)
void ignoreSslErrors(const QList< QSslError > &errors)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\macro QT_RESTRICTED_CAST_FROM_ASCII
~ProtocolHandlerDeleter()
ProtocolHandlerDeleter(QAbstractProtocolHandler *h)
The QTcpSocket class provides a TCP socket.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
bool is_protocol_upgraded(const QHttpNetworkReply &reply)
void appendProtocolUpgradeHeaders(const QHttp2Configuration &config, QHttpNetworkRequest *request)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
DBusConnection * connection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static const int reconnectAttemptsDefault
QPair< QHttpNetworkRequest, QHttpNetworkReply * > HttpMessagePair
GLenum GLsizei GLuint GLint * bytesWritten
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLsizei const GLchar * message
GLfloat GLfloat GLfloat GLfloat h