Skip to content

HTTP client helpers

mopidy.httpclient

Helpers for configuring HTTP clients used in Mopidy extensions.

Functions:

  • format_proxy

    Convert a Mopidy proxy config to the commonly used proxy string format.

  • format_user_agent

    Construct a User-Agent suitable for use in client code.

format_proxy

format_proxy(proxy_config: ProxyConfig, auth: bool = True) -> str | None

Convert a Mopidy proxy config to the commonly used proxy string format.

Outputs scheme://host:port, scheme://user:pass@host:port or None depending on the proxy config provided.

You can also opt out of getting the basic auth by setting auth to False.

format_user_agent

format_user_agent(name: str | None = None) -> str

Construct a User-Agent suitable for use in client code.

This will identify use by the provided name (which should be on the format dist_name/version), Mopidy version and Python version.