HTTP Core
Do one thing, and do it well.
The HTTP Core package provides a minimal low-level HTTP client, which does one thing only. Sending HTTP requests.
It does not provide any high level model abstractions over the API, does not handle redirects, multipart uploads, building authentication headers, transparent HTTP caching, URL parsing, session cookie handling, content or charset decoding, handling JSON, environment based configuration defaults, or any of that Jazz.
Some things HTTP Core does do:
- Sending HTTP requests.
- Thread-safe / task-safe connection pooling.
- HTTP(S) proxy & SOCKS proxy support.
- Supports HTTP/1.1 and HTTP/2.
- Provides both sync and async interfaces.
- Async backend support for
asyncioandtrio.
Requirements
Python 3.8+
Installation
For HTTP/1.1 only support, install with:
$ pip install httpcore
There are also a number of optional extras available...
$ pip install httpcore['asyncio,trio,http2,socks']Sending requests
Send an HTTP request:
"import httpcore
response = httpcore.request("GET", "https://www.example.com/")
print(response)
#
print(response.status)
# 200
print(response.headers)
# [(b'Accept-Ranges', b'bytes'), (b'Age', b'557328'), (b'Cache-Control', b'max-age=604800'), ...]
print(response.content)
# b'\n \n