Skip to content
Myr

README.md

This file

Path

README.md

206 lines · 5.9 KiB · Markdown

Last changed by

Update READMETom Christiebefore adoption4fe2f69

History of this file

Take it

StuffTom Christiebefore adoption30530d4

lines 1–2why, one step back
1# HTTPCore
2

Truckin' onTom Christiebefore adoption6b60d95

line 3why, one step back
3A proposal for [requests III](https://github.com/kennethreitz/requests3).

Update READMETom Christiebefore adoption665743a

line 4why, one step back
4

Truckin' onTom Christiebefore adoption6b60d95

line 5why, one step back
5## Feature support

Update READMETom Christiebefore adoption665743a

line 6why, one step back
6

Truckin' onTom Christiebefore adoption6b60d95

lines 7–10why, one step back
7* `HTTP/1.1` and `HTTP/2` Support.
8* `async`/`await` support for non-thread-blocking HTTP requests.9* Fully type annotated.10* 100% test coverage. *TODO - We're on ~97% right now*

Update READMETom Christiebefore adoption665743a

line 11why, one step back
11

Truckin' onTom Christiebefore adoption6b60d95

line 12why, one step back
12Plus all the standard features of requests...

Update READMETom Christiebefore adoption665743a

line 13why, one step back
13

Truckin' onTom Christiebefore adoption6b60d95

lines 14–15why, one step back
14* International Domains and URLs
15* Keep-Alive & Connection Pooling

Update READMETom Christiebefore adoptionfa8d296

line 16why, one step back
16* Sessions with Cookie Persistence *TODO - Requires `adapters/cookies.py` implementation.*

Truckin' onTom Christiebefore adoption6b60d95

line 17why, one step back
17* Browser-style SSL Verification

Update READMETom Christiebefore adoptionfa8d296

line 18why, one step back
18* Basic/Digest Authentication *TODO - Requires `adapters/authentication.py` implementation.*

Truckin' onTom Christiebefore adoption6b60d95

lines 19–22why, one step back
19* Elegant Key/Value Cookies *TODO*
20* Automatic Decompression21* Automatic Content Decoding22* Unicode Response Bodies

Update READMETom Christiebefore adoptionfa8d296

line 23why, one step back
23* Multipart File Uploads *TODO - Request content currently supports bytes or async byte iterators.*

Truckin' onTom Christiebefore adoption6b60d95

lines 24–26why, one step back
24* HTTP(S) Proxy Support *TODO*
25* Connection Timeouts26* Streaming Downloads

Update READMETom Christiebefore adoptionfa8d296

line 27why, one step back
27* .netrc Support *TODO - Requires `adapters/environment.py` implementation.*

Truckin' onTom Christiebefore adoption6b60d95

line 28why, one step back
28* Chunked Requests

Update READMETom Christiebefore adoption665743a

line 29why, one step back
29

Update README.mdTom Christiebefore adoption0d3eb0e

line 30why, one step back
30## Usage

Update README.mdTom Christiebefore adoption01a3c09

line 31why, one step back
31

Update READMETom Christiebefore adoptionfa8d296

lines 32–33why, one step back
32**Note**: Use `ipython` to try this from the console, since it supports `await`.
33

Update README.mdTom Christiebefore adoption337eb70

lines 34–35why, one step back
34Making a request:
35

StuffTom Christiebefore adoption30530d4

line 36why, one step back
36```python

Truckin' onTom Christiebefore adoption6b60d95

lines 37–38why, one step back
37>>> import httpcore
38>>> client = httpcore.Client()

Still truckin' onTom Christiebefore adoption6cb5c0d

line 39why, one step back
39>>> response = await client.get('https://example.com')

Truckin' onTom Christiebefore adoption6b60d95

lines 40–41why, one step back
40>>> response.status_code
41<StatusCode.ok: 200>

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 42–43why, one step back
42>>> response.protocol
43'HTTP/2'

Truckin' onTom Christiebefore adoption6b60d95

lines 44–45why, one step back
44>>> response.text
45'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'

StuffTom Christiebefore adoption30530d4

lines 46–47why, one step back
46```
47

Truckin' onTom Christiebefore adoption6b60d95

line 48why, one step back
48Alternatively, thread-synchronous requests:

StuffTom Christiebefore adoption30530d4

lines 49–50why, one step back
49
50```python

Truckin' onTom Christiebefore adoption6b60d95

lines 51–52why, one step back
51>>> import httpcore
52>>> client = httpcore.SyncClient()

Still truckin' onTom Christiebefore adoption6cb5c0d

line 53why, one step back
53>>> response = client.get('https://example.com')

Truckin' onTom Christiebefore adoption6b60d95

lines 54–55why, one step back
54>>> response.status_code
55<StatusCode.ok: 200>

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 56–57why, one step back
56>>> response.protocol
57'HTTP/2'

Truckin' onTom Christiebefore adoption6b60d95

lines 58–59why, one step back
58>>> response.text
59'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'

StuffTom Christiebefore adoption30530d4

lines 60–61why, one step back
60```
61

Truckin' onTom Christiebefore adoption6b60d95

line 62why, one step back
62---

StuffTom Christiebefore adoption30530d4

line 63why, one step back
63

Update READMETom Christiebefore adoption4fe2f69

lines 64–77why, one step back
64## Dependencies
6566* `h11` - HTTP/1.1 support.67* `h2` - HTTP/2 support.68* `certifi` - SSL certificates.69* `chardet` - Fallback auto-detection for response encoding.70* `idna` - Internationalized domain name support.71* `rfc3986` - URL parsing & normalization.72* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*7374Additionally, credit is due to for `urllib3` for plenty of design inspiration.7576---77

Truckin' onTom Christiebefore adoption6b60d95

line 78why, one step back
78## API Reference

Update READMETom Christiebefore adoption68b80dc

line 79why, one step back
79

Truckin' onTom Christiebefore adoption6b60d95

line 80why, one step back
80#### `Client([ssl], [timeout], [pool_limits], [max_redirects])`

Update READMETom Christiebefore adoption68b80dc

line 81why, one step back
81

Update READMETom Christiebefore adoption4fe2f69

lines 82–89why, one step back
82* `async def .request(method, url, [content], [headers], [stream], [allow_redirects], [ssl], [timeout])`
83* `async def .get(url, [headers], [stream], [allow_redirects], [ssl], [timeout])`84* `async def .options(url, [headers], [stream], [allow_redirects], [ssl], [timeout])`85* `async def .head(url, [headers], [stream], [allow_redirects], [ssl], [timeout])`86* `async def .post(url, [content], [headers], [stream], [allow_redirects], [ssl], [timeout])`87* `async def .put(url, [content], [headers], [stream], [allow_redirects], [ssl], [timeout])`88* `async def .patch(url, [content], [headers], [stream], [allow_redirects], [ssl], [timeout])`89* `async def .delete(url, [content], [headers], [stream], [allow_redirects], [ssl], [timeout])`

Still truckin' onTom Christiebefore adoption6cb5c0d

line 90why, one step back
90* `def .prepare_request(request)`

Update READMETom Christiebefore adoption4fe2f69

line 91why, one step back
91* `async def .send(request, [stream], [allow_redirects], [ssl], [timeout])`

Still truckin' onTom Christiebefore adoption6cb5c0d

line 92why, one step back
92* `async def .close()`

Update README.mdTom Christiebefore adoption01a3c09

line 93why, one step back
93

Truckin' onTom Christiebefore adoption6b60d95

line 94why, one step back
94### Models

README tweaksTom Christiebefore adoption8e1a263

line 95why, one step back
95

Truckin' onTom Christiebefore adoption6b60d95

line 96why, one step back
96#### `Response(...)`

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 97why, one step back
97

Update READMETom Christiebefore adoption4fe2f69

line 98why, one step back
98*An HTTP response.*

Still truckin' onTom Christiebefore adoption6cb5c0d

line 99why, one step back
99

Truckin' onTom Christiebefore adoption6b60d95

lines 100–111why, one step back
100* `.status_code` - **int**
101* `.reason_phrase` - **str**102* `.protocol` - `"HTTP/2"` or `"HTTP/1.1"`103* `.url` - **URL**104* `.headers` - **Headers**105* `.content` - **bytes**106* `.text` - **str**107* `.encoding` - **str**108* `.is_redirect` - **bool**109* `.request` - **Request**110* `.cookies` - **Cookies** *TODO*111* `.history` - **List[Response]**

Update READMETom Christiebefore adoptionfa8d296

lines 112–119why, one step back
112* `def .raise_for_status()` - **Response** *TODO*
113* `def .json()` - **Any** *TODO*114* `async def .read()` - **bytes**115* `async def .stream()` - **bytes iterator**116* `async def .raw()` - **bytes iterator**117* `async def .close()` - **None**118* `async def .next()` - **Response**119

Truckin' onTom Christiebefore adoption6b60d95

lines 120–121why, one step back
120#### `Request(method, url, content, headers)`
121

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 122–129why, one step back
122*An HTTP request. Can be constructed explicitly for more control over exactly
123what gets sent over the wire.*124125```python126>>> request = Request("GET", "http://example.org", headers={'host': 'example.org'})127>>> response = await client.send(request)128```129

Update READMETom Christiebefore adoptionfa8d296

lines 130–133why, one step back
130* `.method` - **str** (Uppercased)
131* `.url` - **URL**132* `.content` - **byte** or **byte async iterator**133* `.headers` - **Headers**

Truckin' onTom Christiebefore adoption6b60d95

lines 134–150why, one step back
134
135#### `URL(url, allow_relative=False)`136137*A normalized, IDNA supporting URL.*138139* `.scheme` - **str**140* `.authority` - **str**141* `.host` - **str**142* `.port` - **int**143* `.path` - **str**144* `.query` - **str**145* `.full_path` - **str**146* `.fragment` - **str**147* `.is_ssl` - **bool**148* `.origin` - **Origin**149* `.is_absolute_url` - **bool**150* `.is_relative_url` - **bool**

Update READMETom Christiebefore adoptionfa8d296

lines 151–152why, one step back
151* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**
152* `def .resolve_with(url)` - **URL**

Truckin' onTom Christiebefore adoption6b60d95

lines 153–157why, one step back
153
154#### `Origin(url)`155156*A normalized, IDNA supporting set of scheme/host/port info.*157

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 158why, one step back
158```python

Truckin' onTom Christiebefore adoption6b60d95

lines 159–160why, one step back
159>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')
160True

README tweaksTom Christiebefore adoption8e1a263

lines 161–162why, one step back
161```
162

Truckin' onTom Christiebefore adoption6b60d95

lines 163–165why, one step back
163* `.is_ssl` - **bool**
164* `.host` - **str**165* `.port` - **int**

Added proxy exampleTom Christiebefore adoption87b21b0

line 166why, one step back
166

Truckin' onTom Christiebefore adoption6b60d95

line 167why, one step back
167#### `Headers(headers)`

Added proxy exampleTom Christiebefore adoption87b21b0

line 168why, one step back
168

Truckin' onTom Christiebefore adoption6b60d95

lines 169–170why, one step back
169*A case-insensitive multi-dict.*
170

Added proxy exampleTom Christiebefore adoption87b21b0

line 171why, one step back
171```python

Truckin' onTom Christiebefore adoption6b60d95

lines 172–175why, one step back
172>>> headers = Headers({'Content-Type': 'application/json'})
173>>> headers['content-type']174'application/json'175```

Added proxy exampleTom Christiebefore adoption87b21b0

line 176why, one step back
176

Truckin' onTom Christiebefore adoption6b60d95

line 177why, one step back
177___

Added proxy exampleTom Christiebefore adoption87b21b0

line 178why, one step back
178

Truckin' onTom Christiebefore adoption6b60d95

line 179why, one step back
179## Alternate backends

Added proxy exampleTom Christiebefore adoption87b21b0

line 180why, one step back
180

Truckin' onTom Christiebefore adoption6b60d95

line 181why, one step back
181### `SyncClient`

Added proxy exampleTom Christiebefore adoption87b21b0

line 182why, one step back
182

Truckin' onTom Christiebefore adoption6b60d95

line 183why, one step back
183A thread-synchronous client.

Added proxy exampleTom Christiebefore adoption87b21b0

line 184why, one step back
184

Truckin' onTom Christiebefore adoption6b60d95

line 185why, one step back
185### `TrioClient`

Added proxy exampleTom Christiebefore adoption87b21b0

line 186why, one step back
186

Truckin' onTom Christiebefore adoption6b60d95

line 187why, one step back
187*TODO*

Added proxy exampleTom Christiebefore adoption87b21b0

line 188why, one step back
188

Truckin' onTom Christiebefore adoption6b60d95

line 189why, one step back
189---

Added proxy exampleTom Christiebefore adoption87b21b0

line 190why, one step back
190

Truckin' onTom Christiebefore adoption6b60d95

line 191why, one step back
191## The Stack

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 192why, one step back
192

Truckin' onTom Christiebefore adoption6b60d95

line 193why, one step back
193The `httpcore` client builds up behavior in a modular way.

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 194why, one step back
194

Truckin' onTom Christiebefore adoption6b60d95

line 195why, one step back
195This 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.

Added proxy exampleTom Christiebefore adoption87b21b0

line 196why, one step back
196

Truckin' onTom Christiebefore adoption6b60d95

line 197why, one step back
197You can also use lower level components in isolation if required, eg. Use a `ConnectionPool` without providing sessions, redirects etc...

Added proxy exampleTom Christiebefore adoption87b21b0

line 198why, one step back
198

Truckin' onTom Christiebefore adoption6b60d95

lines 199–206why, one step back
199* `RedirectAdapter` - Adds redirect support.
200* `EnvironmentAdapter` - Adds `.netrc` and envvars such as `REQUESTS_CA_BUNDLE`.201* `CookieAdapter` - Adds cookie persistence.202* `AuthAdapter` - Adds authentication support.203* `ConnectionPool` - Connection pooling & keep alive.204 * `HTTPConnection` - A single connection.205 * `HTTP11Connection` - A single HTTP/1.1 connection.206 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.