Skip to content

PythonQt.Qt.QNetworkProxyQuery

QNetworkProxyQuery

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

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:

  • the type of query
  • the local port number to use
  • the destination host name
  • the destination port number
  • the protocol name, such as "http" or "ftp"
  • the URL being requested

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.

Query type Description
TcpSocket Normal sockets requesting a connection to a remote server, like QTcpSocket. The peer hostname and peer port match the values passed to QTcpSocket::connectToHost(). The local port is usually -1, indicating the socket has no preference in which port should be used. The URL component is not used.
UdpSocket Datagram-based sockets, which can both send and receive. The local port, remote host or remote port fields can all be used or be left unused, depending on the characteristics of the socket. The URL component is not used.
SctpSocket Message-oriented sockets requesting a connection to a remote server. The peer hostname and peer port match the values passed to QSctpSocket::connectToHost(). The local port is usually -1, indicating the socket has no preference in which port should be used. The URL component is not used.
TcpServer Passive server sockets that listen on a port and await incoming connections from the network. Normally, only the local port is used, but the remote address could be used in specific circumstances, for example to indicate which remote host a connection is expected from. The URL component is not used.
UrlRequest A more high-level request, such as those coming from QNetworkAccessManager. These requests will inevitably use an outgoing TCP socket, but the this query type is provided to indicate that more detailed information is present in the URL component. For ease of implementation, the URL's host and port are set as the destination address.
SctpServer Passive server sockets that listen on an SCTP port and await incoming connections from the network. Normally, only the local port is used, but the remote address could be used in specific circumstances, for example to indicate which remote host a connection is expected from. The URL component is not used.

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.

Source: https://doc.qt.io/archives/qt-5.15/qnetworkproxyquery.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
QueryType attribute type Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text)
TcpServer attribute QueryType (shared captured text)
TcpSocket attribute QueryType (shared captured text)
UdpSocket attribute QueryType (shared captured text)
UrlRequest attribute QueryType (shared captured text)
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
localPort function (self) -> int X.localPort() -> int (shared captured text)
networkConfiguration function (self) -> Any X.networkConfiguration() -> PythonQt.QtNetwork.QNetworkConfiguration (shared captured text)
peerHostName function (self) -> str X.peerHostName() -> str (shared captured text)
peerPort function (self) -> int X.peerPort() -> int (shared captured text)
protocolTag function (self) -> str X.protocolTag() -> str (shared captured text)
queryType function (self) -> Any Returns the query type. (shared captured text)
setLocalPort function (self, port: int) -> None Sets the port number that the socket wishes to use locally to accept incoming packets from remote servers to port. (shared captured text)
setNetworkConfiguration function (self, networkConfiguration: Any) -> None (shared captured text)
setPeerHostName function (self, hostname: str) -> None Sets the hostname of the outgoing connection being requested to hostname. (shared captured text)
setPeerPort function (self, port: int) -> None Sets the requested port number for the outgoing connection to be port. (shared captured text)
setProtocolTag function (self, protocolTag: str) -> None Sets the protocol tag for this [QNetworkProxyQuery](https://doc.qt.io/archives/qt-5.15/qnetworkproxyquery.html) object to be protocolTag. (shared captured text)
setQueryType function (self, type: Any) -> None Sets the query type of this object to be type. (shared captured text)
setUrl function (self, url: Any) -> None Sets the URL component of this [QNetworkProxyQuery](https://doc.qt.io/archives/qt-5.15/qnetworkproxyquery.html) object to be url. (shared captured text)
swap function (self, other: Any) -> None Swaps this network proxy query instance with other. (shared captured text)
url function (self) -> Any X.url() -> PythonQt.QtCore.QUrl (shared captured text)