Skip to content
Myr

Update README

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by Tom Christie · parent b6c27f0 · Browse files · 1 file+33 added−38 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+33 added−38 removed

  • other:+33 added−38 removed

1 file+33 added−38 removed

modified:README.md+33 added-38 removed
20 unmodified lines
21Plus all the standard features of requests...2223* International Domains and URLs24* Keep-Alive & Connection Pooling25* Sessions with Cookie Persistence *TODO - Requires `adapters/cookies.py` implementation.*25* Sessions with Cookie Persistence *TODO*26* Browser-style SSL Verification27* Basic/Digest Authentication *TODO - Requires `adapters/authentication.py` implementation.*27* Basic/Digest Authentication *TODO*28* Elegant Key/Value Cookies *TODO*29* Automatic Decompression30* Automatic Content Decoding31* Unicode Response Bodies32* Multipart File Uploads *TODO - Request content currently supports URL encoded data, bytes, or async byte iterators.*33* HTTP(S) Proxy Support *TODO*34* Connection Timeouts35* Streaming Downloads36* .netrc Support *TODO - Requires `adapters/environment.py` implementation.*36* .netrc Support *TODO*37* Chunked Requests3839## Usage4041**Note**: Use `ipython` to try this from the console, since it supports `await`.4241Making a request:4243```python44>>> import httpcore45>>> client = httpcore.Client()48>>> response = await client.get('https://example.com')46>>> response = client.get('https://example.com')47>>> response.status_code48<StatusCode.ok: 200>49>>> response.protocol50'HTTP/2'51>>> response.text52'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'53```5457Alternatively, thread-synchronous requests:55Alternatively, async requests:5657**Note**: Use `ipython` to try this from the console, since it supports `await`.5859```python60>>> import httpcore61>>> client = httpcore.SyncClient()62>>> response = client.get('https://example.com')61>>> client = httpcore.AsyncClient()62>>> response = await client.get('https://example.com')63>>> response.status_code64<StatusCode.ok: 200>65>>> response.protocol66'HTTP/2'
12 unmodified lines
79* `idna` - Internationalized domain name support.80* `rfc3986` - URL parsing & normalization.81* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*8283A huge amount of credit is due to `requests`, for the API layout that83A huge amount of credit is due to `requests` for the API layout that84much of this work follows, as well as to `urllib3` for plenty of design85inspiration around the lower level networking details.8687---
8 unmodified lines
96>>> client = Client()97>>> response = await client.get('https://example.org')98```99100* `def __init__([ssl], [timeout], [pool_limits], [max_redirects])`101* `async def .request(method, url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102* `async def .get(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103* `async def .options(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104* `async def .head(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105* `async def .post(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106* `async def .put(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107* `async def .patch(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`108* `async def .delete(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`100* `def __init__([ssl], [timeout], [pool_limits], [max_redirects], [dispatch])`101* `def .request(method, url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102* `def .get(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103* `def .options(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104* `def .head(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105* `def .post(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106* `def .put(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107* `def .patch(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`108* `def .delete(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`109* `def .prepare_request(request)`110* `async def .send(request, [stream], [allow_redirects], [ssl], [timeout])`111* `async def .close()`110* `def .send(request, [stream], [allow_redirects], [ssl], [timeout])`111* `def .close()`112113### `Response`114115*An HTTP response.*
12 unmodified lines
128* `.cookies` - **Cookies** *TODO*129* `.history` - **List[Response]**130* `def .raise_for_status()` - **None**131* `def .json()` - **Any** *TODO*132* `async def .read()` - **bytes**133* `async def .stream()` - **bytes iterator**134* `async def .raw()` - **bytes iterator**135* `async def .close()` - **None**136* `async def .next()` - **Response**132* `def .read()` - **bytes**133* `def .stream()` - **bytes iterator**134* `def .raw()` - **bytes iterator**135* `def .close()` - **None**136* `def .next()` - **Response**137138### `Request`139140*An HTTP request. Can be constructed explicitly for more control over exactly
65 unmodified lines
206___207208## Alternate backends209210### `SyncClient`210### `AsyncClient`211212A thread-synchronous client.212An asyncio client.213214### `TrioClient`215216*TODO*
1 unmodified line
218---219220## The Stack221222The `httpcore` client builds up behavior in a modular way.222There are two main layers in the stack. The client handles redirection,223cookie persistence (TODO), and authentication (TODO). The dispatcher224handles sending the actual request and getting the response.225224This makes it easier to dig into an understand the behaviour of any one aspect in isolation, as well as making it easier to test or to adapt for custom behaviors.225226You can also use lower level components in isolation if required, eg. Use a `ConnectionPool` without providing sessions, redirects etc...227228* `RedirectAdapter` - Adds redirect support.229* `EnvironmentAdapter` - Adds `.netrc` and envvars such as `REQUESTS_CA_BUNDLE`.230* `CookieAdapter` - Adds cookie persistence.231* `AuthAdapter` - Adds authentication support.232* `ConnectionPool` - Connection pooling & keep alive.226* `Client` - Redirect, authentication, cookies etc.227* `ConnectionPool(Dispatcher)` - Connection pooling & keep alive.228 * `HTTPConnection` - A single connection.229 * `HTTP11Connection` - A single HTTP/1.1 connection.230 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.