QNetworkProxy Class Reference
来源:互联网 发布:移动网络怎么转换器 编辑:程序博客网 时间:2024/05/16 17:18
QNetworkProxy Class Reference
The QNetworkProxy class provides a network layer proxy. More...
Note: All functions in this class are reentrant.
This class was introduced in Qt 4.1.
- List of all members, including inherited members
Public Types
flagsCapabilitiesenumCapability { TunnelingCapability, ListeningCapability, UdpTunnelingCapability, CachingCapability, HostNameLookupCapability }enumProxyType { NoProxy, DefaultProxy, Socks5Proxy, HttpProxy, HttpCachingProxy, FtpCachingProxy }Public Functions
QNetworkProxy () QNetworkProxy ( ProxyType type, const QString & hostName = QString(), quint16 port = 0, const QString & user = QString(), const QString & password = QString() ) QNetworkProxy ( const QNetworkProxy & other ) ~QNetworkProxy ()Capabilitiescapabilities () constQStringhostName () constboolisCachingProxy () constboolisTransparentProxy () constQStringpassword () constquint16port () constvoidsetCapabilities ( Capabilities capabilities )voidsetHostName ( const QString & hostName )voidsetPassword ( const QString & password )voidsetPort ( quint16 port )voidsetType ( QNetworkProxy::ProxyType type )voidsetUser ( const QString & user )QNetworkProxy::ProxyTypetype () constQStringuser () constbooloperator!= ( const QNetworkProxy & other ) constQNetworkProxy &operator= ( const QNetworkProxy & other )booloperator== ( const QNetworkProxy & other ) constStatic Public Members
QNetworkProxyapplicationProxy ()voidsetApplicationProxy ( const QNetworkProxy & networkProxy )Detailed Description
The QNetworkProxy class provides a network layer proxy.
QNetworkProxy provides the method for configuring network layer proxy support to the Qt network classes. The currently supported classes are QAbstractSocket,QTcpSocket, QUdpSocket, QTcpServer, QNetworkAccessManager and QFtp. The proxy support is designed to be as transparent as possible. This means that existing network-enabled applications that you have written should automatically support network proxy using the following code.
An alternative to setting an application wide proxy is to specify the proxy for individual sockets using QAbstractSocket::setProxy() and QTcpServer::setProxy(). In this way, it is possible to disable the use of a proxy for specific sockets using the following code:
Network proxy is not used if the address used in connectToHost(), bind() or listen() is equivalent to QHostAddress::LocalHost or QHostAddress::LocalHostIPv6.
Each type of proxy support has certain restrictions associated with it. You should read the ProxyType documentation carefully before selecting a proxy type to use.
Note: Changes made to currently connected sockets do not take effect. If you need to change a connected socket, you should reconnect it.
SOCKS5
The SOCKS5 support in Qt 4 is based on RFC 1928 and RFC 1929. The supported authentication methods are no authentication and username/password authentication. Both IPv4 and IPv6 are supported. Domain names are resolved through the SOCKS5 server if the QNetworkProxy::HostNameLookupCapability is enabled, otherwise they are resolved locally and the IP address is sent to the server. There are several things to remember when using SOCKS5 with QUdpSocket and QTcpServer:
With QUdpSocket, a call to bind() may fail with a timeout error. If a port number other than 0 is passed to bind(), it is not guaranteed that it is the specified port that will be used. Use localPort() and localAddress() to get the actual address and port number in use. Because proxied UDP goes through two UDP connections, it is more likely that packets will be dropped.
With QTcpServer a call to listen() may fail with a timeout error. If a port number other than 0 is passed to listen(), then it is not guaranteed that it is the specified port that will be used. Use serverPort() and serverAddress() to get the actual address and port used to listen for connections. SOCKS5 only supports one accepted connection per call tolisten(), and each call is likely to result in a different serverPort() being used.
See also QAbstractSocket and QTcpServer.
Member Type Documentation
enum QNetworkProxy::Capability
flags QNetworkProxy::Capabilities
These flags indicate the capabilities that a given proxy server supports.
QNetworkProxy sets different capabilities by default when the object is created (see QNetworkProxy::ProxyType for a list of the defaults). However, it is possible to change the capabitilies after the object has been created with setCapabilities().
The capabilities that QNetworkProxy supports are:
This enum was introduced or modified in Qt 4.5.
The Capabilities type is a typedef for QFlags<Capability>. It stores an OR combination of Capability values.
enum QNetworkProxy::ProxyType
This enum describes the types of network proxying provided in Qt.
There are two types of proxies that Qt understands: transparent proxies and caching proxies. The first group consists of proxies that can handle any arbitrary data transfer, while the second can only handle specific requests. The caching proxies only make sense for the specific classes where they can be used.
The table below lists different proxy types and their capabilities. Since each proxy type has different capabilities, it is important to understand them before choosing a proxy type.
Also note that you shouldn't set the application default proxy (setApplicationProxy()) to a proxy that doesn't have the TunnelingCapability capability. If you do, QTcpSocketwill not know how to open connections.
See also setType(), type(), capabilities(), and setCapabilities().
Member Function Documentation
QNetworkProxy::QNetworkProxy ()
Constructs a QNetworkProxy with DefaultProxy type; the proxy type is determined by applicationProxy(), which defaults to NoProxy.
See also setType() and setApplicationProxy().
QNetworkProxy::QNetworkProxy ( ProxyType type, const QString & hostName = QString(), quint16 port = 0, const QString & user = QString(), const QString & password = QString() )
Constructs a QNetworkProxy with type, hostName, port, user and password.
The default capabilities for proxy type type are set automatically.
See also capabilities().
QNetworkProxy::QNetworkProxy ( const QNetworkProxy & other )
Constructs a copy of other.
QNetworkProxy::~QNetworkProxy ()
Destroys the QNetworkProxy object.
QNetworkProxy QNetworkProxy::applicationProxy () [static]
Returns the application level network proxying.
If a QAbstractSocket or QTcpSocket has the QNetworkProxy::DefaultProxy type, then the QNetworkProxy returned by this function is used.
See also QNetworkProxyFactory, setApplicationProxy(), QAbstractSocket::proxy(), and QTcpServer::proxy().
Capabilities QNetworkProxy::capabilities () const
Returns the capabilities of this proxy server.
This function was introduced in Qt 4.5.
See also setCapabilities() and type().
QString QNetworkProxy::hostName () const
Returns the host name of the proxy host.
See also setHostName(), setPort(), and port().
bool QNetworkProxy::isCachingProxy () const
Returns true if this proxy supports the QNetworkProxy::CachingCapability capability.
In Qt 4.4, the capability was tied to the proxy type, but since Qt 4.5 it is possible to remove the capability of caching from a proxy by calling setCapabilities().
This function was introduced in Qt 4.4.
See also capabilities(), type(), and isTransparentProxy().
bool QNetworkProxy::isTransparentProxy () const
Returns true if this proxy supports transparent tunneling of TCP connections. This matches the QNetworkProxy::TunnelingCapability capability.
In Qt 4.4, the capability was tied to the proxy type, but since Qt 4.5 it is possible to remove the capability of caching from a proxy by calling setCapabilities().
This function was introduced in Qt 4.4.
See also capabilities(), type(), and isCachingProxy().
QString QNetworkProxy::password () const
Returns the password used for authentication.
See also user(), setPassword(), and setUser().
quint16 QNetworkProxy::port () const
Returns the port of the proxy host.
See also setHostName(), setPort(), and hostName().
void QNetworkProxy::setApplicationProxy ( const QNetworkProxy & networkProxy ) [static]
Sets the application level network proxying to be networkProxy.
If a QAbstractSocket or QTcpSocket has the QNetworkProxy::DefaultProxy type, then the QNetworkProxy set with this function is used. If you want more flexibility in determining which the proxy, use the QNetworkProxyFactory class.
Setting a default proxy value with this function will override the application proxy factory set with QNetworkProxyFactory::setApplicationProxyFactory.
See also QNetworkProxyFactory, applicationProxy(), QAbstractSocket::setProxy(), and QTcpServer::setProxy().
void QNetworkProxy::setCapabilities ( Capabilities capabilities )
Sets the capabilities of this proxy to capabilities.
This function was introduced in Qt 4.5.
See also setType() and capabilities().
void QNetworkProxy::setHostName ( const QString & hostName )
Sets the host name of the proxy host to be hostName.
See also hostName(), setPort(), and port().
void QNetworkProxy::setPassword ( const QString & password )
Sets the password for proxy authentication to be password.
See also user(), setUser(), and password().
void QNetworkProxy::setPort ( quint16 port )
Sets the port of the proxy host to be port.
See also hostName(), setHostName(), and port().
void QNetworkProxy::setType ( QNetworkProxy::ProxyType type )
Sets the proxy type for this instance to be type.
Note that changing the type of a proxy does not change the set of capabilities this QNetworkProxy object holds if any capabilities have been set with setCapabilities().
See also type() and setCapabilities().
void QNetworkProxy::setUser ( const QString & user )
Sets the user name for proxy authentication to be user.
See also user(), setPassword(), and password().
QNetworkProxy::ProxyType QNetworkProxy::type () const
Returns the proxy type for this instance.
See also setType().
QString QNetworkProxy::user () const
Returns the user name used for authentication.
See also setUser(), setPassword(), and password().
bool QNetworkProxy::operator!= ( const QNetworkProxy & other ) const
Compares the value of this network proxy to other and returns true if they differ.
This function was introduced in Qt 4.4.
QNetworkProxy & QNetworkProxy::operator= ( const QNetworkProxy & other )
Assigns the value of the network proxy other to this network proxy.
This function was introduced in Qt 4.2.
bool QNetworkProxy::operator== ( const QNetworkProxy & other ) const
Compares the value of this network proxy to other and returns true if they are equal (same proxy type, server as well as username and password)
This function was introduced in Qt 4.4.
- QNetworkProxy Class Reference
- QProcess Class Reference
- UITableView Class Reference
- CCTransitionScene Class Reference
- UIPageControl Class Reference翻译
- Hierarchical_State_Machine Class Reference
- UIViewController Class Reference
- QTableModel Class Reference
- QwtSplineCurveFitter Class Reference
- UITabBarController Class Reference
- wxAppConsole Class Reference
- UIViewController Class Reference
- QPrinter Class Reference
- QWebView Class Reference
- CBATTRequest Class Reference
- CBCentral Class Reference
- CBCentralManager Class Reference
- CAAnimation Class Reference
- struct tcphdr
- 环境变量路径中有空格该怎么办
- 更改openDocument默认的URL路径
- 转:Render RenderContents RenderControl 三个方法的区别
- iOS7新特性-NSURLSession详解
- QNetworkProxy Class Reference
- Linux常用命令
- 内存管理内幕--动态分配的选择、折衷和实现
- 使用JavaServiceWrapper把Java程序作为Windows系统服务 from http://www.233.com
- TCP协议详解
- Tornado+nginx+supervisor 在生产环境上部署
- 网页设计-从零开始 百度文库
- Unity3D中的弹道和移动目标提前量计算
- 开源项目的各种协议简单介绍