httpx

Developer Interface

Helper Functions

!!! note Only use these functions if you’re testing HTTPX in a console or making a small number of requests. Using a Client will enable HTTP/2 and connection pooling for more efficient and long-lived connections.

::: httpx.request :docstring:

::: httpx.get :docstring:

::: httpx.options :docstring:

::: httpx.head :docstring:

::: httpx.post :docstring:

::: httpx.put :docstring:

::: httpx.patch :docstring:

::: httpx.delete :docstring:

::: httpx.stream :docstring:

Client

::: httpx.Client :docstring: :members: headers cookies params auth request get head options post put patch delete stream build_request send close

AsyncClient

::: httpx.AsyncClient :docstring: :members: headers cookies params auth request get head options post put patch delete stream build_request send aclose

Response

An HTTP response.

Request

An HTTP request. Can be constructed explicitly for more control over exactly what gets sent over the wire.

>>> request = httpx.Request("GET", "https://example.org", headers={'host': 'example.org'})
>>> response = client.send(request)

URL

A normalized, IDNA supporting URL.

>>> url = URL("https://example.org/")
>>> url.host
'example.org'

Headers

A case-insensitive multi-dict.

>>> headers = Headers({'Content-Type': 'application/json'})
>>> headers['content-type']
'application/json'

Cookies

A dict-like cookie store.

>>> cookies = Cookies()
>>> cookies.set("name", "value", domain="example.org")

Proxy

A configuration of the proxy server.

>>> proxy = Proxy("http://proxy.example.com:8030")
>>> client = Client(proxy=proxy)