robot-piglet d28c55ab25 Intermediate changes | 1 year ago | |
---|---|---|
.. | ||
.dist-info | 1 year ago | |
httpcore | 1 year ago | |
LICENSE.md | 1 year ago | |
README.md | 1 year ago | |
ya.make | 1 year ago |
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:
asyncio
and trio
.Python 3.8+
For HTTP/1.1 only support, install with:
$ pip install httpcore
For HTTP/1.1 and HTTP/2 support, install with:
$ pip install httpcore[http2]
For SOCKS proxy support, install with:
$ pip install httpcore[socks]
Send an HTTP request:
import httpcore
response = httpcore.request("GET", "https://www.example.com/")
print(response)
# <Response [200]>
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'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n\n<meta charset="utf-8"/>\n ...'
The top-level httpcore.request()
function is provided for convenience. In practice whenever you're working with httpcore
you'll want to use the connection pooling functionality that it provides.
import httpcore
http = httpcore.ConnectionPool()
response = http.request("GET", "https://www.example.com/")
Once you're ready to get going, head over to the documentation.
You probably don't want to be using HTTP Core directly. It might make sense if
you're writing something like a proxy service in Python, and you just want
something at the lowest possible level, but more typically you'll want to use
a higher level client library, such as httpx
.
The motivation for httpcore
is: