diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 2f93c5fa2b..e68c5076b3 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -914,7 +914,7 @@ void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port) proxies << proxy; } else { // try the application settings instead - QNetworkProxyQuery query(hostname, port, QString(), + QNetworkProxyQuery query(hostname, port, protocolTag, socketType == QAbstractSocket::TcpSocket ? QNetworkProxyQuery::TcpSocket : socketType == QAbstractSocket::SctpSocket ? @@ -2959,6 +2959,38 @@ QNetworkProxy QAbstractSocket::proxy() const Q_D(const QAbstractSocket); return d->proxy; } + +/*! + \since 5.13 + + Returns the protocol tag for this socket. + If the protocol tag is set then this is passed to QNetworkProxyQuery + when this is created internally to indicate the protocol tag to be + used. + + \sa setProtocolTag(), QNetworkProxyQuery +*/ + +QString QAbstractSocket::protocolTag() const +{ + Q_D(const QAbstractSocket); + return d->protocolTag; +} + +/*! + \since 5.13 + + Sets the protocol tag for this socket to \a tag. + + \sa protocolTag() +*/ + +void QAbstractSocket::setProtocolTag(const QString &tag) +{ + Q_D(QAbstractSocket); + d->protocolTag = tag; +} + #endif // QT_NO_NETWORKPROXY #ifndef QT_NO_DEBUG_STREAM diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 6d5e57ac52..de09195eeb 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -197,6 +197,8 @@ public: #ifndef QT_NO_NETWORKPROXY void setProxy(const QNetworkProxy &networkProxy); QNetworkProxy proxy() const; + QString protocolTag() const; + void setProtocolTag(const QString &tag); #endif Q_SIGNALS: diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index 066a35ff85..38c0caef49 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -124,6 +124,7 @@ public: #ifndef QT_NO_NETWORKPROXY QNetworkProxy proxy; QNetworkProxy proxyInUse; + QString protocolTag; void resolveProxy(const QString &hostName, quint16 port); #else inline void resolveProxy(const QString &, quint16) { } diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 270e81774d..8b7d48be15 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1977,6 +1977,7 @@ void QSslSocket::connectToHost(const QString &hostName, quint16 port, OpenMode o d->createPlainSocket(openMode); } #ifndef QT_NO_NETWORKPROXY + d->plainSocket->setProtocolTag(d->protocolTag); d->plainSocket->setProxy(proxy()); #endif QIODevice::open(openMode);