![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QNetworkProxyQuery class is used to query the proxy settings for a socket. More...
#include <qnetworkproxy.h>
Public Types | |
enum | QueryType { TcpSocket , UdpSocket , SctpSocket , TcpServer = 100 , UrlRequest , SctpServer } |
Describes the type of one QNetworkProxyQuery query. More... | |
Public Member Functions | |
QNetworkProxyQuery () | |
Constructs a default QNetworkProxyQuery object. | |
QNetworkProxyQuery (const QUrl &requestUrl, QueryType queryType=UrlRequest) | |
Constructs a QNetworkProxyQuery with the URL requestUrl and sets the query type to queryType. | |
QNetworkProxyQuery (const QString &hostname, int port, const QString &protocolTag=QString(), QueryType queryType=TcpSocket) | |
Constructs a QNetworkProxyQuery of type queryType and sets the protocol tag to be protocolTag. | |
QNetworkProxyQuery (quint16 bindPort, const QString &protocolTag=QString(), QueryType queryType=TcpServer) | |
Constructs a QNetworkProxyQuery of type queryType and sets the protocol tag to be protocolTag. | |
QNetworkProxyQuery (const QNetworkProxyQuery &other) | |
Constructs a QNetworkProxyQuery object that is a copy of other. | |
QNetworkProxyQuery & | operator= (QNetworkProxyQuery &&other) noexcept |
QNetworkProxyQuery & | operator= (const QNetworkProxyQuery &other) |
Copies the contents of other. | |
~QNetworkProxyQuery () | |
Destroys this QNetworkProxyQuery object. | |
void | swap (QNetworkProxyQuery &other) noexcept |
bool | operator== (const QNetworkProxyQuery &other) const |
Returns true if this QNetworkProxyQuery object contains the same data as other. | |
bool | operator!= (const QNetworkProxyQuery &other) const |
Returns true if this QNetworkProxyQuery object does not contain the same data as other. | |
QueryType | queryType () const |
Returns the query type. | |
void | setQueryType (QueryType type) |
Sets the query type of this object to be type. | |
int | peerPort () const |
Returns the port number for the outgoing request or -1 if the port number is not known. | |
void | setPeerPort (int port) |
Sets the requested port number for the outgoing connection to be port. | |
QString | peerHostName () const |
Returns the host name or IP address being of the outgoing connection being requested, or an empty string if the remote hostname is not known. | |
void | setPeerHostName (const QString &hostname) |
Sets the hostname of the outgoing connection being requested to hostname. | |
int | localPort () const |
Returns the port number of the socket that will accept incoming packets from remote servers or -1 if the port is not known. | |
void | setLocalPort (int port) |
Sets the port number that the socket wishes to use locally to accept incoming packets from remote servers to port. | |
QString | protocolTag () const |
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol tag is unknown. | |
void | setProtocolTag (const QString &protocolTag) |
Sets the protocol tag for this QNetworkProxyQuery object to be protocolTag. | |
QUrl | url () const |
Returns the URL component of this QNetworkProxyQuery object in case of a query of type QNetworkProxyQuery::UrlRequest. | |
void | setUrl (const QUrl &url) |
Sets the URL component of this QNetworkProxyQuery object to be url. | |
The QNetworkProxyQuery class is used to query the proxy settings for a socket.
\inmodule QtNetwork
QNetworkProxyQuery holds the details of a socket being created or request being made. It is used by QNetworkProxy and QNetworkProxyFactory to allow applications to have a more fine-grained control over which proxy servers are used, depending on the details of the query. This allows an application to apply different settings, according to the protocol or destination hostname, for instance.
QNetworkProxyQuery supports the following criteria for selecting the proxy:
\list
The destination host name is the host in the connection in the case of outgoing connection sockets. It is the hostName
parameter passed to QTcpSocket::connectToHost() or the host component of a URL requested with QNetworkRequest.
The destination port number is the requested port to connect to in the case of outgoing sockets, while the local port number is the port the socket wishes to use locally before attempting the external connection. In most cases, the local port number is used by listening sockets only (QTcpSocket) or by datagram sockets (QUdpSocket).
The protocol name is an arbitrary string that indicates the type of connection being attempted. For example, it can match the scheme of a URL, like "http", "https" and "ftp". In most cases, the proxy selection will not change depending on the protocol, but this information is provided in case a better choice can be made, like choosing an caching HTTP proxy for HTTP-based connections, but a more powerful SOCKSv5 proxy for all others.
Some of the criteria may not make sense in all of the types of query. The following table lists the criteria that are most commonly used, according to the type of query.
\table \header
\row
\row
\row
\row
\row
\row
It should be noted that any of the criteria may be missing or unknown (an empty QString for the hostname or protocol name, -1 for the port numbers). If that happens, the functions executing the query should make their best guess or apply some implementation-defined default values.
Definition at line 20 of file qnetworkproxy.h.
Describes the type of one QNetworkProxyQuery query.
\value TcpSocket a normal, outgoing TCP socket \value UdpSocket a datagram-based UDP socket, which could send to multiple destinations \value SctpSocket a message-oriented, outgoing SCTP socket \value TcpServer a TCP server that listens for incoming connections from the network \value UrlRequest a more complex request which involves loading of a URL \value SctpServer an SCTP server that listens for incoming connections from the network
Enumerator | |
---|---|
TcpSocket | |
UdpSocket | |
SctpSocket | |
TcpServer | |
UrlRequest | |
SctpServer |
Definition at line 25 of file qnetworkproxy.h.
QNetworkProxyQuery::QNetworkProxyQuery | ( | ) |
Constructs a default QNetworkProxyQuery object.
By default, the query type will be QNetworkProxyQuery::TcpSocket.
Definition at line 1081 of file qnetworkproxy.cpp.
|
explicit |
Constructs a QNetworkProxyQuery with the URL requestUrl and sets the query type to queryType.
Definition at line 1091 of file qnetworkproxy.cpp.
QNetworkProxyQuery::QNetworkProxyQuery | ( | const QString & | hostname, |
int | port, | ||
const QString & | protocolTag = QString(), | ||
QueryType | queryType = TcpSocket ) |
Constructs a QNetworkProxyQuery of type queryType and sets the protocol tag to be protocolTag.
This constructor is suitable for QNetworkProxyQuery::TcpSocket queries, because it sets the peer hostname to hostname and the peer's port number to port.
Definition at line 1104 of file qnetworkproxy.cpp.
|
explicit |
Constructs a QNetworkProxyQuery of type queryType and sets the protocol tag to be protocolTag.
This constructor is suitable for QNetworkProxyQuery::TcpSocket queries because it sets the local port number to bindPort.
Note that bindPort is of type quint16 to indicate the exact port number that is requested. The value of -1 (unknown) is not allowed in this context.
Definition at line 1126 of file qnetworkproxy.cpp.
QNetworkProxyQuery::QNetworkProxyQuery | ( | const QNetworkProxyQuery & | other | ) |
Constructs a QNetworkProxyQuery object that is a copy of other.
Definition at line 1137 of file qnetworkproxy.cpp.
QNetworkProxyQuery::~QNetworkProxyQuery | ( | ) |
Destroys this QNetworkProxyQuery object.
Definition at line 1145 of file qnetworkproxy.cpp.
int QNetworkProxyQuery::localPort | ( | ) | const |
Returns the port number of the socket that will accept incoming packets from remote servers or -1 if the port is not known.
Definition at line 1267 of file qnetworkproxy.cpp.
|
inline |
Returns true
if this QNetworkProxyQuery object does not contain the same data as other.
Definition at line 49 of file qnetworkproxy.h.
QNetworkProxyQuery & QNetworkProxyQuery::operator= | ( | const QNetworkProxyQuery & | other | ) |
Copies the contents of other.
Definition at line 1153 of file qnetworkproxy.cpp.
|
inlinenoexcept |
Definition at line 42 of file qnetworkproxy.h.
bool QNetworkProxyQuery::operator== | ( | const QNetworkProxyQuery & | other | ) | const |
Returns true
if this QNetworkProxyQuery object contains the same data as other.
Definition at line 1169 of file qnetworkproxy.cpp.
QString QNetworkProxyQuery::peerHostName | ( | ) | const |
Returns the host name or IP address being of the outgoing connection being requested, or an empty string if the remote hostname is not known.
If the query type is QNetworkProxyQuery::UrlRequest, this function returns the host component of the URL being requested.
Definition at line 1239 of file qnetworkproxy.cpp.
int QNetworkProxyQuery::peerPort | ( | ) | const |
Returns the port number for the outgoing request or -1 if the port number is not known.
If the query type is QNetworkProxyQuery::UrlRequest, this function returns the port number of the URL being requested. In general, frameworks will fill in the port number from their default values.
Definition at line 1207 of file qnetworkproxy.cpp.
QString QNetworkProxyQuery::protocolTag | ( | ) | const |
Returns the protocol tag for this QNetworkProxyQuery object, or an empty QString in case the protocol tag is unknown.
In the case of queries of type QNetworkProxyQuery::UrlRequest, this function returns the value of the scheme component of the URL.
Definition at line 1305 of file qnetworkproxy.cpp.
QNetworkProxyQuery::QueryType QNetworkProxyQuery::queryType | ( | ) | const |
Returns the query type.
Definition at line 1184 of file qnetworkproxy.cpp.
void QNetworkProxyQuery::setLocalPort | ( | int | port | ) |
Sets the port number that the socket wishes to use locally to accept incoming packets from remote servers to port.
The local port is most often used with the QNetworkProxyQuery::TcpServer and QNetworkProxyQuery::UdpSocket query types.
Valid values are 0 to 65535 (with 0 indicating that any port number will be acceptable) or -1, which means the local port number is unknown or not applicable.
In some circumstances, for special protocols, it's the local port number can also be used with a query of type QNetworkProxyQuery::TcpSocket. When that happens, the socket is indicating it wishes to use the port number port when connecting to a remote host.
Definition at line 1290 of file qnetworkproxy.cpp.
Sets the hostname of the outgoing connection being requested to hostname.
An empty hostname can be used to indicate that the remote host is unknown.
The peer host name can also be used to indicate the expected source address of an incoming connection in the case of QNetworkProxyQuery::UdpSocket or QNetworkProxyQuery::TcpServer query types.
Definition at line 1256 of file qnetworkproxy.cpp.
void QNetworkProxyQuery::setPeerPort | ( | int | port | ) |
Sets the requested port number for the outgoing connection to be port.
Valid values are 1 to 65535, or -1 to indicate that the remote port number is unknown.
The peer port number can also be used to indicate the expected port number of an incoming connection in the case of QNetworkProxyQuery::UdpSocket or QNetworkProxyQuery::TcpServer query types.
Definition at line 1224 of file qnetworkproxy.cpp.
Sets the protocol tag for this QNetworkProxyQuery object to be protocolTag.
The protocol tag is an arbitrary string that indicates which protocol is being talked over the socket, such as "http", "xmpp", "telnet", etc. The protocol tag is used by the backend to return a request that is more specific to the protocol in question: for example, a HTTP connection could be use a caching HTTP proxy server, while all other connections use a more powerful SOCKSv5 proxy server.
Definition at line 1324 of file qnetworkproxy.cpp.
Sets the query type of this object to be type.
Definition at line 1192 of file qnetworkproxy.cpp.
Sets the URL component of this QNetworkProxyQuery object to be url.
Setting the URL will also set the protocol tag, the remote host name and port number. This is done so as to facilitate the implementation of the code that determines the proxy server to be used.
Definition at line 1349 of file qnetworkproxy.cpp.
|
inlinenoexcept |
Definition at line 46 of file qnetworkproxy.h.
QUrl QNetworkProxyQuery::url | ( | ) | const |
Returns the URL component of this QNetworkProxyQuery object in case of a query of type QNetworkProxyQuery::UrlRequest.
Definition at line 1335 of file qnetworkproxy.cpp.