QNetworkProxyFactoryclass provides fine-grained proxy selection. 更多 …
def
queryProxy
([query=QNetworkProxyQuery()])
def
proxyForQuery
(query)
def
setApplicationProxyFactory
(factory)
def
setUseSystemConfiguration
(enable)
def
systemProxyForQuery
([query=QNetworkProxyQuery()])
def
usesSystemConfiguration
()
QNetworkProxyFactoryis an extension toQNetworkProxy,允许应用程序对使用哪种代理服务器有更细粒度控制 (从属套接字请求代理)。例如,这允许应用程序根据协议或目标主机名应用不同设置。
QNetworkProxyFactorycan be set globally for an application, in which case it will override any global proxies set withsetApplicationProxy(). If set globally, any sockets created with Qt will query the factory to determine the proxy to be used.也可以在支持多个连接的某些框架中设置工厂,譬如
QNetworkAccessManager。当在这种对象上设置时,将只查询由该框架创建的套接字的工厂。
You can configure a factory to use the system proxy’s settings. Call the
setUseSystemConfiguration()function with true to enable this behavior, or false to disable it.同样,可以使用工厂以直接查询系统代理通过调用其
systemProxyForQuery()函数。警告
Depending on the configuration of the user’s system, the use of system proxy features on certain platforms may be subject to limitations. The
systemProxyForQuery()documentation contains a list of these limitations for those platforms that are affected.
QNetworkProxyFactory
¶
创建
QNetworkProxyFactory
对象。
Since
QNetworkProxyFactory
is an abstract class, you cannot create objects of type
QNetworkProxyFactory
directly.
PySide2.QtNetwork.QNetworkProxyFactory.
proxyForQuery
(
query
)
¶
query
–
QNetworkProxyQuery
此函数接受查询请求
query
,审查套接字或请求类型的细节,并返回列表为
QNetworkProxy
对象 (按首选次序指示要使用的代理服务器)。
PySide2.QtNetwork.QNetworkProxyFactory.
queryProxy
(
[
query=QNetworkProxyQuery()
]
)
¶
query
–
QNetworkProxyQuery
此函数接受查询请求
query
,审查套接字或请求类型的细节,并返回列表为
QNetworkProxy
对象 (按首选次序指示要使用的代理服务器)。
当重实现此类时,小心至少要返回一元素。
若无法确定更好的代理替代方案,使用
DefaultProxy
,它告诉代码查询代理以使用更高替代。例如,若把此工厂设置给
QNetworkAccessManager
对象,DefaultProxy 将告诉它以查询应用程序级代理设置。
若此工厂被设置为应用程序代理工厂,DefaultProxy 和 Noproxy 将拥有相同含义。
PySide2.QtNetwork.QNetworkProxyFactory.
setApplicationProxyFactory
(
factory
)
¶
factory
–
QNetworkProxyFactory
把应用程序范围代理工厂设为
factory
。此函数将拥有该对象的所有权,并在必要时删除它。
应用程序范围代理被用作最后手段,当所有其他代理选择请求返回
DefaultProxy
。例如,
QTcpSocket
对象可以拥有代理设置采用
setProxy
,但若设为 none,将查询采用此函数设置的代理工厂类。
若采用此函数设置代理工厂,则任何应用程序级代理设置采用
setApplicationProxy
将被覆盖,且
usesSystemConfiguration()
will return
false
.
PySide2.QtNetwork.QNetworkProxyFactory.
setUseSystemConfiguration
(
enable
)
¶
enable
–
bool
启用特定平台代理设置的使用,且只使用那些。见
systemProxyForQuery()
了解更多信息。
调用此函数采用
enable
设为
true
重置任何代理或
QNetworkProxyFactory
已经设置。
注意
见
systemProxyForQuery()
documentation for a list of limitations related to the use of system proxies.
PySide2.QtNetwork.QNetworkProxyFactory.
systemProxyForQuery
(
[
query=QNetworkProxyQuery()
]
)
¶
query
–
QNetworkProxyQuery
此函数接受查询请求
query
,审查套接字或请求类型的细节,并返回列表为
QNetworkProxy
对象 (按首选次序指示要使用的代理服务器)。
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
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 SystemConfiguration 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 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”.
这些是此函数当前版本的局限性。未来版本的 Qt 可能消除这里列出的某些局限性。
在 macOS,此函数会忽略 Proxy Auto Configuration (代理自动配置) 设置,因为它不能执行关联 ECMAcript 代码。
On Windows platforms, this function may take several seconds to execute depending on the configuration of the user’s system.
PySide2.QtNetwork.QNetworkProxyFactory.
usesSystemConfiguration
(
)
¶
bool
返回是否已启用特定平台代理设置的使用。