Skip to content

NetworkProxy

Qt Base Class: QNetworkProxy

Signature: QNetworkProxy(self) -> None QNetworkProxy(self, other: Union[PySide6.QtNetwork.QNetworkProxy, PySide6.QtNetwork.QNetworkProxy.ProxyType]) -> None QNetworkProxy(self, type: PySide6.QtNetwork.QNetworkProxy.ProxyType, hostName: str = '', port: int = 0, user: str = '', password: str = '') -> None

Base classes

Name Children Inherits
QNetworkProxy
PySide6.QtNetwork
QNetworkProxy(self) -> None

⋔ Inheritance diagram

graph TD
  1473574000736["network.NetworkProxy"]
  1473573290176["QtNetwork.QNetworkProxy"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473573290176 --> 1473574000736
  1473291690208 --> 1473573290176
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QNetworkProxy

Network layer proxy.

Source code in prettyqt\network\networkproxy.py
class NetworkProxy(network.QNetworkProxy):
    """Network layer proxy."""

    def get_capabilities(self) -> list[CapabilityStr]:
        return CAPABILITIES.get_list(self.capabilities())

    def set_capabilities(self, *capability: CapabilityStr):
        flags = CAPABILITIES.merge_flags(capability)
        self.setCapabilities(flags)

    def get_header(
        self,
        name: network.networkrequest.KnownHeaderStr | network.NetworkRequest.KnownHeaders,
    ) -> str:
        return self.header(network.networkrequest.KNOWN_HEADER.get_enum_value(name))

    def set_header(
        self,
        name: network.networkrequest.KnownHeaderStr | network.NetworkRequest.KnownHeaders,
        value: str,
    ):
        self.setHeader(network.networkrequest.KNOWN_HEADER.get_enum_value(name), value)

    def get_headers(self) -> dict[str, str]:
        return {
            h.data().decode(): self.rawHeader(h).data().decode()
            for h in self.rawHeaderList()
        }

    def set_headers(self, headers: dict[str, str]):
        for k, v in headers.items():
            self.setRawHeader(
                QtCore.QByteArray(k.encode()), QtCore.QByteArray(v.encode())
            )

    def set_type(self, typ: ProxyTypeStr | network.QNetworkProxy.ProxyType):
        """Set proxy type.

        Args:
            typ: proxy type
        """
        self.setType(PROXY_TYPES.get_enum_value(typ))

    def get_type(self) -> ProxyTypeStr:
        """Get the proxy type.

        Returns:
            type
        """
        return PROXY_TYPES.inverse[self.type()]

get_type() -> ProxyTypeStr

Get the proxy type.

Source code in prettyqt\network\networkproxy.py
def get_type(self) -> ProxyTypeStr:
    """Get the proxy type.

    Returns:
        type
    """
    return PROXY_TYPES.inverse[self.type()]

set_type(typ: ProxyTypeStr | network.QNetworkProxy.ProxyType)

Set proxy type.

Parameters:

Name Type Description Default
typ ProxyTypeStr | ProxyType

proxy type

required
Source code in prettyqt\network\networkproxy.py
def set_type(self, typ: ProxyTypeStr | network.QNetworkProxy.ProxyType):
    """Set proxy type.

    Args:
        typ: proxy type
    """
    self.setType(PROXY_TYPES.get_enum_value(typ))