Skip to content

rnet.proxy

Proxy settings for HTTP, HTTPS, and SOCKS proxies.

rnet.proxy

ProxyConfig

Bases: TypedDict

Source code in rnet/proxy.py
class ProxyConfig(TypedDict):
    username: NotRequired[str]
    r"""Username for proxy authentication."""

    password: NotRequired[str]
    r"""Password for proxy authentication."""

    custom_http_auth: NotRequired[str]
    r"""Custom HTTP proxy authentication header value."""

    custom_http_headers: NotRequired[Dict[str, str] | HeaderMap]
    r"""Custom HTTP proxy headers."""

    exclusion: NotRequired[str]
    r"""List of domains to exclude from proxying."""

username instance-attribute

username

Username for proxy authentication.

password instance-attribute

password

Password for proxy authentication.

custom_http_auth instance-attribute

custom_http_auth

Custom HTTP proxy authentication header value.

custom_http_headers instance-attribute

custom_http_headers

Custom HTTP proxy headers.

exclusion instance-attribute

exclusion

List of domains to exclude from proxying.

Proxy

A proxy server for a request. Supports HTTP, HTTPS, SOCKS4, SOCKS4a, SOCKS5, and SOCKS5h protocols.

Source code in rnet/proxy.py
@final
class Proxy:
    r"""
    A proxy server for a request.
    Supports HTTP, HTTPS, SOCKS4, SOCKS4a, SOCKS5, and SOCKS5h protocols.
    """

    @staticmethod
    def http(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
        r"""
        Creates a new HTTP proxy.

        This method sets up a proxy server for HTTP requests.

        # Examples

        ```python
        import rnet

        proxy = rnet.Proxy.http("http://proxy.example.com")
        ```
        """
        ...

    @staticmethod
    def https(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
        r"""
        Creates a new HTTPS proxy.

        This method sets up a proxy server for HTTPS requests.

        # Examples

        ```python
        import rnet

        proxy = rnet.Proxy.https("https://proxy.example.com")
        ```
        """
        ...

    @staticmethod
    def all(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
        r"""
        Creates a new proxy for all protocols.

        This method sets up a proxy server for all types of requests (HTTP, HTTPS, etc.).

        # Examples

        ```python
        import rnet

        proxy = rnet.Proxy.all("https://proxy.example.com")
        ```
        """
        ...

    @staticmethod
    def unix(path: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
        r"""
        Creates a new UNIX socket proxy.

        This method sets up a proxy server using a UNIX domain socket.

        # Examples

        ```python
        import rnet

        proxy = rnet.Proxy.unix("/var/run/docker.sock")
        ```
        """
        ...

    def __str__(self) -> str: ...

http staticmethod

http(url, **kwargs)

Creates a new HTTP proxy.

This method sets up a proxy server for HTTP requests.

Examples
import rnet

proxy = rnet.Proxy.http("http://proxy.example.com")
Source code in rnet/proxy.py
@staticmethod
def http(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
    r"""
    Creates a new HTTP proxy.

    This method sets up a proxy server for HTTP requests.

    # Examples

    ```python
    import rnet

    proxy = rnet.Proxy.http("http://proxy.example.com")
    ```
    """
    ...

https staticmethod

https(url, **kwargs)

Creates a new HTTPS proxy.

This method sets up a proxy server for HTTPS requests.

Examples
import rnet

proxy = rnet.Proxy.https("https://proxy.example.com")
Source code in rnet/proxy.py
@staticmethod
def https(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
    r"""
    Creates a new HTTPS proxy.

    This method sets up a proxy server for HTTPS requests.

    # Examples

    ```python
    import rnet

    proxy = rnet.Proxy.https("https://proxy.example.com")
    ```
    """
    ...

all staticmethod

all(url, **kwargs)

Creates a new proxy for all protocols.

This method sets up a proxy server for all types of requests (HTTP, HTTPS, etc.).

Examples
import rnet

proxy = rnet.Proxy.all("https://proxy.example.com")
Source code in rnet/proxy.py
@staticmethod
def all(url: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
    r"""
    Creates a new proxy for all protocols.

    This method sets up a proxy server for all types of requests (HTTP, HTTPS, etc.).

    # Examples

    ```python
    import rnet

    proxy = rnet.Proxy.all("https://proxy.example.com")
    ```
    """
    ...

unix staticmethod

unix(path, **kwargs)

Creates a new UNIX socket proxy.

This method sets up a proxy server using a UNIX domain socket.

Examples
import rnet

proxy = rnet.Proxy.unix("/var/run/docker.sock")
Source code in rnet/proxy.py
@staticmethod
def unix(path: str, **kwargs: Unpack[ProxyConfig]) -> "Proxy":
    r"""
    Creates a new UNIX socket proxy.

    This method sets up a proxy server using a UNIX domain socket.

    # Examples

    ```python
    import rnet

    proxy = rnet.Proxy.unix("/var/run/docker.sock")
    ```
    """
    ...