Add a means to specify the protocol type, to aid websockets over proxy
When a PAC script is used on macOS, it will only allow connections for http/https, although a proxy can be used for ws/wss. Therefore we need to add a means of setting the protocol type for this sort of connection so that we can pass on the necessary information to the PAC script. Change-Id: I3fa29fa85a529bd88d9565daa58fe9d748b61a92 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
3464e1e5c7
commit
e25d7b1441
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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) { }
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user