Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httpx-socks

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpx-socks

Proxy (HTTP, SOCKS) transports for httpx

  • 0.9.2
  • PyPI
  • Socket score

Maintainers
1

httpx-socks

CI Coverage Status PyPI version

The httpx-socks package provides proxy transports for httpx client. SOCKS4(a), SOCKS5(h), HTTP (tunneling) proxy supported. It uses python-socks for core proxy functionality.

Requirements

  • Python >= 3.6
  • httpx>=0.21.0
  • python-socks>=2.0.0
  • async-timeout>=3.0.1 (optional)
  • trio>=0.16.0 (optional)

Installation

only sync proxy support:

pip install httpx-socks

to include optional asyncio support (it requires async-timeout):

pip install httpx-socks[asyncio]

to include optional trio support:

pip install httpx-socks[trio]

Usage

sync transport
import httpx
from httpx_socks import SyncProxyTransport

def fetch(url):
    transport = SyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
    with httpx.Client(transport=transport) as client:
        res = client.get(url)
        return res.text
async transport (asyncio, trio)
import httpx
from httpx_socks import AsyncProxyTransport

async def fetch(url):
    transport = AsyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
    async with httpx.AsyncClient(transport=transport) as client:
        res = await client.get(url)
        return res.text
secure proxy connections (aka "HTTPS proxies", experimental feature, both sync and async support)
import ssl
import httpx
from httpx_socks import AsyncProxyTransport

async def fetch(url):
    proxy_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS)
    proxy_ssl.verify_mode = ssl.CERT_REQUIRED
    proxy_ssl.load_verify_locations(...)
    
    transport = AsyncProxyTransport.from_url('http://user:password@127.0.0.1:8080', proxy_ssl=proxy_ssl)
    async with httpx.AsyncClient(transport=transport) as client:
        res = await client.get(url)
        return res.text

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc