191#ifndef QT_NO_NETWORKPROXY
193#include "private/qnetworkrequest_p.h"
195#include "private/qsocks5socketengine_p.h"
199#include "private/qhttpsocketengine_p.h"
221 : applicationLevelProxy(
nullptr)
222 , applicationLevelProxyFactory(
nullptr)
224 , socks5SocketEngineHandler(
nullptr)
227 , httpSocketEngineHandler(
nullptr)
229#ifdef QT_USE_SYSTEM_PROXIES
230 , useSystemProxies(true)
232 , useSystemProxies(
false)
245 delete applicationLevelProxy;
246 delete applicationLevelProxyFactory;
248 delete socks5SocketEngineHandler;
251 delete httpSocketEngineHandler;
257 return useSystemProxies;
263 useSystemProxies =
enable;
265 if (useSystemProxies) {
266 if (applicationLevelProxy)
268 delete applicationLevelProxyFactory;
269 applicationLevelProxyFactory =
nullptr;
276 if (!applicationLevelProxy)
278 *applicationLevelProxy =
proxy;
279 delete applicationLevelProxyFactory;
280 applicationLevelProxyFactory =
nullptr;
281 useSystemProxies =
false;
287 if (
factory == applicationLevelProxyFactory)
289 if (applicationLevelProxy)
291 delete applicationLevelProxyFactory;
292 applicationLevelProxyFactory =
factory;
293 useSystemProxies =
false;
313 bool useSystemProxies;
325 if (hostname ==
"localhost"_L1 || hostname.
startsWith(
"localhost."_L1)
331 if (!applicationLevelProxyFactory) {
332 if (applicationLevelProxy
334 result << *applicationLevelProxy;
335 }
else if (useSystemProxies) {
352 qWarning(
"QNetworkProxyFactory: factory %p has returned an empty result set",
353 applicationLevelProxyFactory);
362 template<
bool>
struct StaticAssertTest;
363 template<>
struct StaticAssertTest<true> {
enum { Value = 1 }; };
367#define q_static_assert(expr) qt_noop_with_arg(sizeof(StaticAssertTest< expr >::Value))
407 return QNetworkProxy::Capabilities(
defaults[
int(
type)]);
447 if (
d &&
d->ref.loadRelaxed() == 1)
452 if (
d && !
d->ref.deref())
471 globalNetworkProxy();
489 globalNetworkProxy();
709 return d ? d->
port : 0;
729 if (globalNetworkProxy()) {
734 globalNetworkProxy()->setApplicationProxy(networkProxy);
749 if (globalNetworkProxy())
891 if (
d &&
d->ref.loadRelaxed() == 1)
896 if (
d && !
d->ref.deref())
1379 if (globalNetworkProxy())
1380 return globalNetworkProxy()->usesSystemConfiguration();
1398 if (globalNetworkProxy())
1399 globalNetworkProxy()->setUseSystemConfiguration(
enable);
1422 if (globalNetworkProxy())
1423 globalNetworkProxy()->setApplicationProxyFactory(
factory);
1505 if (!globalNetworkProxy())
1507 return globalNetworkProxy()->proxyForQuery(
query);
1510#ifndef QT_NO_DEBUG_STREAM
1514 debug.resetFormat().nospace();
1518 debug <<
"NoProxy ";
1521 debug <<
"DefaultProxy ";
1524 debug <<
"Socks5Proxy ";
1527 debug <<
"HttpProxy ";
1530 debug <<
"HttpCachingProxy ";
1533 debug <<
"FtpCachingProxy ";
1556 debug <<
'[' << scaps.join(u
' ') <<
']';
1563 debug.resetFormat().nospace()
1567 <<
", peerPort: " << proxyQuery.
peerPort()
1569 <<
", localPort: " << proxyQuery.
localPort()
1570 <<
", url: " << proxyQuery.
url()
1578#include "moc_qnetworkproxy.cpp"
bool usesSystemConfiguration() const
QList< QNetworkProxy > proxyForQuery(const QNetworkProxyQuery &query)
void setUseSystemConfiguration(bool enable)
void setApplicationProxyFactory(QNetworkProxyFactory *factory)
void setApplicationProxy(const QNetworkProxy &proxy)
QNetworkProxy applicationProxy()
T value(const Key &key) const noexcept
The QHostAddress class provides an IP address.
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
const T & constFirst() const noexcept
const_iterator constEnd() const noexcept
const_iterator ConstIterator
The QNetworkProxyFactory class provides fine-grained proxy selection.
static bool usesSystemConfiguration()
virtual QList< QNetworkProxy > queryProxy(const QNetworkProxyQuery &query=QNetworkProxyQuery())=0
This function takes the query request, query, examines the details of the type of socket or request a...
static void setUseSystemConfiguration(bool enable)
static QList< QNetworkProxy > systemProxyForQuery(const QNetworkProxyQuery &query=QNetworkProxyQuery())
This function takes the query request, query, examines the details of the type of socket or request a...
static void setApplicationProxyFactory(QNetworkProxyFactory *factory)
Sets the application-wide proxy factory to be factory.
static QList< QNetworkProxy > proxyForQuery(const QNetworkProxyQuery &query)
This function takes the query request, query, examines the details of the type of socket or request a...
QNetworkProxyFactory()
Creates a QNetworkProxyFactory object.
virtual ~QNetworkProxyFactory()
Destroys the QNetworkProxyFactory object.
QNetworkProxyPrivate(QNetworkProxy::ProxyType t=QNetworkProxy::DefaultProxy, const QString &h=QString(), quint16 p=0, const QString &u=QString(), const QString &pw=QString())
bool operator==(const QNetworkProxyPrivate &other) const
QNetworkProxy::ProxyType type
QNetworkProxy::Capabilities capabilities
QNetworkHeadersPrivate headers
QNetworkProxyQuery::QueryType type
bool operator==(const QNetworkProxyQueryPrivate &other) const
QNetworkProxyQueryPrivate()
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
void setPeerPort(int port)
Sets the requested port number for the outgoing connection to be port.
QueryType
Describes the type of one QNetworkProxyQuery query.
int peerPort() const
Returns the port number for the outgoing request or -1 if the port number is not known.
int localPort() const
Returns the port number of the socket that will accept incoming packets from remote servers or -1 if ...
~QNetworkProxyQuery()
Destroys this QNetworkProxyQuery object.
void setUrl(const QUrl &url)
Sets the URL component of this QNetworkProxyQuery object to be url.
QString peerHostName() const
Returns the host name or IP address being of the outgoing connection being requested,...
QueryType queryType() const
Returns the query type.
void setPeerHostName(const QString &hostname)
Sets the hostname of the outgoing connection being requested to hostname.
void setQueryType(QueryType type)
Sets the query type of this object to be type.
QNetworkProxyQuery & operator=(QNetworkProxyQuery &&other) noexcept
QNetworkProxyQuery()
Constructs a default QNetworkProxyQuery object.
QString protocolTag() const
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol...
void setLocalPort(int port)
Sets the port number that the socket wishes to use locally to accept incoming packets from remote ser...
bool operator==(const QNetworkProxyQuery &other) const
Returns true if this QNetworkProxyQuery object contains the same data as other.
QUrl url() const
Returns the URL component of this QNetworkProxyQuery object in case of a query of type QNetworkProxyQ...
void setProtocolTag(const QString &protocolTag)
Sets the protocol tag for this QNetworkProxyQuery object to be protocolTag.
The QNetworkProxy class provides a network layer proxy.
QVariant header(QNetworkRequest::KnownHeaders header) const
static QNetworkProxy applicationProxy()
Returns the application level network proxying.
ProxyType
This enum describes the types of network proxying provided in Qt.
bool isCachingProxy() const
QString user() const
Returns the user name used for authentication.
QNetworkProxy()
Constructs a QNetworkProxy with DefaultProxy type.
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
void setHostName(const QString &hostName)
Sets the host name of the proxy host to be hostName.
void setRawHeader(const QByteArray &headerName, const QByteArray &value)
void setCapabilities(Capabilities capab)
void setUser(const QString &userName)
Sets the user name for proxy authentication to be user.
QNetworkProxy & operator=(QNetworkProxy &&other) noexcept
bool operator==(const QNetworkProxy &other) const
Capabilities capabilities() const
~QNetworkProxy()
Destroys the QNetworkProxy object.
QByteArray rawHeader(const QByteArray &headerName) const
bool isTransparentProxy() const
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
QList< QByteArray > rawHeaderList() const
static void setApplicationProxy(const QNetworkProxy &proxy)
Sets the application level network proxying to be networkProxy.
void setType(QNetworkProxy::ProxyType type)
Sets the proxy type for this instance to be type.
bool hasRawHeader(const QByteArray &headerName) const
QString password() const
Returns the password used for authentication.
QString hostName() const
Returns the host name of the proxy host.
void setPassword(const QString &password)
Sets the password for proxy authentication to be password.
@ SctpTunnelingCapability
@ HostNameLookupCapability
@ SctpListeningCapability
void setPort(quint16 port)
Sets the port of the proxy host to be port.
quint16 port() const
Returns the port of the proxy host.
KnownHeaders
List of known header types that QNetworkRequest parses.
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
QString scheme() const
Returns the scheme of the URL.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
void setHost(const QString &host, ParsingMode mode=DecodedMode)
Sets the host of the URL to host.
int port(int defaultPort=-1) const
void setPort(int port)
Sets the port of the URL to port.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
static void qt_noop_with_arg(int)
static QNetworkProxy::Capabilities defaultCapabilitiesForType(QNetworkProxy::ProxyType type)
QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
#define q_static_assert(expr)
static QByteArray headerValue(QNetworkRequest::KnownHeaders header, const QVariant &value)
static QByteArray headerName(QNetworkRequest::KnownHeaders header)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat GLfloat h
#define QStringLiteral(str)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
QFile defaults(defaultsPath)
QUrl url("example.com")
[constructor-url-reference]
QItemEditorFactory * factory