Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QNetworkProxyFactory Class Referenceabstract

The QNetworkProxyFactory class provides fine-grained proxy selection. More...

#include <qnetworkproxy.h>

+ Collaboration diagram for QNetworkProxyFactory:

Public Member Functions

 QNetworkProxyFactory ()
 Creates a QNetworkProxyFactory object.
 
virtual ~QNetworkProxyFactory ()
 Destroys the QNetworkProxyFactory object.
 
virtual QList< QNetworkProxyqueryProxy (const QNetworkProxyQuery &query=QNetworkProxyQuery())=0
 This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.
 

Static Public Member Functions

static bool usesSystemConfiguration ()
 
static void setUseSystemConfiguration (bool enable)
 
static void setApplicationProxyFactory (QNetworkProxyFactory *factory)
 Sets the application-wide proxy factory to be factory.
 
static QList< QNetworkProxyproxyForQuery (const QNetworkProxyQuery &query)
 This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.
 
static QList< QNetworkProxysystemProxyForQuery (const QNetworkProxyQuery &query=QNetworkProxyQuery())
 This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.
 

Detailed Description

The QNetworkProxyFactory class provides fine-grained proxy selection.

Since
4.5

\inmodule QtNetwork

QNetworkProxyFactory is an extension to QNetworkProxy, allowing applications to have a more fine-grained control over which proxy servers are used, depending on the socket requesting the proxy. This allows an application to apply different settings, according to the protocol or destination hostname, for instance.

QNetworkProxyFactory can be set globally for an application, in which case it will override any global proxies set with QNetworkProxy::setApplicationProxy(). If set globally, any sockets created with Qt will query the factory to determine the proxy to be used.

A factory can also be set in certain frameworks that support multiple connections, such as QNetworkAccessManager. When set on such object, the factory will be queried for sockets created by that framework only.

Definition at line 160 of file qnetworkproxy.h.

Constructor & Destructor Documentation

◆ QNetworkProxyFactory()

QNetworkProxyFactory::QNetworkProxyFactory ( )

Creates a QNetworkProxyFactory object.

Since QNetworkProxyFactory is an abstract class, you cannot create objects of type QNetworkProxyFactory directly.

Definition at line 1408 of file qnetworkproxy.cpp.

◆ ~QNetworkProxyFactory()

QNetworkProxyFactory::~QNetworkProxyFactory ( )
virtual

Destroys the QNetworkProxyFactory object.

Definition at line 1415 of file qnetworkproxy.cpp.

Member Function Documentation

◆ proxyForQuery()

QList< QNetworkProxy > QNetworkProxyFactory::proxyForQuery ( const QNetworkProxyQuery & query)
static

This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

Definition at line 1550 of file qnetworkproxy.cpp.

References QNetworkProxy::NoProxy.

Referenced by QNativeSocketEnginePrivate::checkProxy(), QNetworkAccessManagerPrivate::queryProxy(), QTcpServerPrivate::resolveProxy(), and QAbstractSocketPrivate::resolveProxy().

+ Here is the caller graph for this function:

◆ queryProxy()

QList< QNetworkProxy > QNetworkProxyFactory::queryProxy ( const QNetworkProxyQuery & query = QNetworkProxyQuery())
pure virtual

This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

When reimplementing this class, take care to return at least one element.

If you cannot determine a better proxy alternative, use QNetworkProxy::DefaultProxy, which tells the code querying for a proxy to use a higher alternative. For example, if this factory is set to a QNetworkAccessManager object, DefaultProxy will tell it to query the application-level proxy settings.

If this factory is set as the application proxy factory, DefaultProxy and NoProxy will have the same meaning.

Referenced by QGlobalNetworkProxy::proxyForQuery(), and QNetworkAccessManagerPrivate::queryProxy().

+ Here is the caller graph for this function:

◆ setApplicationProxyFactory()

void QNetworkProxyFactory::setApplicationProxyFactory ( QNetworkProxyFactory * factory)
static

Sets the application-wide proxy factory to be factory.

This function will take ownership of that object and will delete it when necessary.

The application-wide proxy is used as a last-resort when all other proxy selection requests returned QNetworkProxy::DefaultProxy. For example, QTcpSocket objects can have a proxy set with QTcpSocket::setProxy, but if none is set, the proxy factory class set with this function will be queried.

If you set a proxy factory with this function, any application level proxies set with QNetworkProxy::setApplicationProxy will be overridden, and usesSystemConfiguration() will return {false}.

See also
QNetworkProxy::setApplicationProxy(), QAbstractSocket::proxy(), QAbstractSocket::setProxy()

Definition at line 1467 of file qnetworkproxy.cpp.

References factory.

◆ setUseSystemConfiguration()

void QNetworkProxyFactory::setUseSystemConfiguration ( bool enable)
static
Since
4.6

Enables the use of the platform-specific proxy settings, and only those. See systemProxyForQuery() for more information.

Calling this function with enable set to true resets any proxy or QNetworkProxyFactory that is already set.

Note
See the systemProxyForQuery() documentation for a list of limitations related to the use of system proxies.

Definition at line 1443 of file qnetworkproxy.cpp.

◆ systemProxyForQuery()

QList< QNetworkProxy > QNetworkProxyFactory::systemProxyForQuery ( const QNetworkProxyQuery & query = QNetworkProxyQuery())
static

This function takes the query request, query, examines the details of the type of socket or request and returns a list of QNetworkProxy objects that indicate the proxy servers to be used, in order of preference.

This function can be used to determine the platform-specific proxy settings. This function will use the libraries provided by the operating system to determine the proxy for a given connection, if such libraries exist. If they don't, this function will just return a QNetworkProxy of type QNetworkProxy::NoProxy.

On Windows, this function will use the WinHTTP DLL functions. Despite its name, Microsoft suggests using it for all applications that require network connections, not just HTTP. This will respect the proxy settings set on the registry with the proxycfg.exe tool. If those settings are not found, this function will attempt to obtain Internet Explorer's settings and use them.

On \macos, this function will obtain the proxy settings using the CFNetwork framework from Apple. It will apply the FTP, HTTP and HTTPS proxy configurations for queries that contain the protocol tag "ftp", "http" and "https", respectively. If the SOCKS proxy is enabled in that configuration, this function will use the SOCKS server for all queries. If SOCKS isn't enabled, it will use the HTTPS proxy for all TcpSocket and UrlRequest queries.

On systems configured with libproxy support, this function will rely on libproxy to obtain the proxy settings. Depending on libproxy configurations, this can in turn delegate to desktop settings, environment variables, etc.

On other systems, this function will pick up proxy settings from the "http_proxy" environment variable. This variable must be a URL using one of the following schemes: "http", "socks5" or "socks5h".

Definition at line 44 of file qnetworkproxy_android.cpp.

References QNetworkProxy::HttpProxy, i, QUrl::matches(), networkClass, QNetworkProxy::NoProxy, proxy, and QUrl::RemoveScheme.

Referenced by QGlobalNetworkProxy::proxyForQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ usesSystemConfiguration()

bool QNetworkProxyFactory::usesSystemConfiguration ( )
static
Since
5.8

Returns whether the use of platform-specific proxy settings are enabled.

Definition at line 1424 of file qnetworkproxy.cpp.


The documentation for this class was generated from the following files: