Skip to content
Myr

README.md

This file

Path

README.md

192 lines · 5.0 KiB · Markdown

Last changed by

Still truckin' onTom Christiebefore adoption6cb5c0d

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

Truckin' onTom Christiebefore adoption6b60d95

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

Update READMETom Christiebefore adoption68b80dc

line 65why, one step back
65

Truckin' onTom Christiebefore adoption6b60d95

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

Update READMETom Christiebefore adoption68b80dc

line 67why, one step back
67

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 68–78why, one step back
68* `async def .request(method, url, ...)`
69* `async def .get(url, ...)`70* `async def .options(url, ...)`71* `async def .head(url, ...)`72* `async def .post(url, ...)`73* `async def .put(url, ...)`74* `async def .patch(url, ...)`75* `async def .delete(url, ...)`76* `def .prepare_request(request)`77* `async def .send(request, ...)`78* `async def .close()`

Update README.mdTom Christiebefore adoption01a3c09

line 79why, one step back
79

Truckin' onTom Christiebefore adoption6b60d95

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

README tweaksTom Christiebefore adoption8e1a263

line 81why, one step back
81

Truckin' onTom Christiebefore adoption6b60d95

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

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 83why, one step back
83

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 84–85why, one step back
84*An HTTP response.**
85

Truckin' onTom Christiebefore adoption6b60d95

lines 86–97why, one step back
86* `.status_code` - **int**
87* `.reason_phrase` - **str**88* `.protocol` - `"HTTP/2"` or `"HTTP/1.1"`89* `.url` - **URL**90* `.headers` - **Headers**91* `.content` - **bytes**92* `.text` - **str**93* `.encoding` - **str**94* `.is_redirect` - **bool**95* `.request` - **Request**96* `.cookies` - **Cookies** *TODO*97* `.history` - **List[Response]**

Update READMETom Christiebefore adoptionfa8d296

lines 98–105why, one step back
98* `def .raise_for_status()` - **Response** *TODO*
99* `def .json()` - **Any** *TODO*100* `async def .read()` - **bytes**101* `async def .stream()` - **bytes iterator**102* `async def .raw()` - **bytes iterator**103* `async def .close()` - **None**104* `async def .next()` - **Response**105

Truckin' onTom Christiebefore adoption6b60d95

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

Still truckin' onTom Christiebefore adoption6cb5c0d

lines 108–115why, one step back
108*An HTTP request. Can be constructed explicitly for more control over exactly
109what gets sent over the wire.*110111```python112>>> request = Request("GET", "http://example.org", headers={'host': 'example.org'})113>>> response = await client.send(request)114```115

Update READMETom Christiebefore adoptionfa8d296

lines 116–119why, one step back
116* `.method` - **str** (Uppercased)
117* `.url` - **URL**118* `.content` - **byte** or **byte async iterator**119* `.headers` - **Headers**

Truckin' onTom Christiebefore adoption6b60d95

lines 120–136why, one step back
120
121#### `URL(url, allow_relative=False)`122123*A normalized, IDNA supporting URL.*124125* `.scheme` - **str**126* `.authority` - **str**127* `.host` - **str**128* `.port` - **int**129* `.path` - **str**130* `.query` - **str**131* `.full_path` - **str**132* `.fragment` - **str**133* `.is_ssl` - **bool**134* `.origin` - **Origin**135* `.is_absolute_url` - **bool**136* `.is_relative_url` - **bool**

Update READMETom Christiebefore adoptionfa8d296

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

Truckin' onTom Christiebefore adoption6b60d95

lines 139–143why, one step back
139
140#### `Origin(url)`141142*A normalized, IDNA supporting set of scheme/host/port info.*143

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

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

Truckin' onTom Christiebefore adoption6b60d95

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

README tweaksTom Christiebefore adoption8e1a263

lines 147–148why, one step back
147```
148

Truckin' onTom Christiebefore adoption6b60d95

lines 149–151why, one step back
149* `.is_ssl` - **bool**
150* `.host` - **str**151* `.port` - **int**

Added proxy exampleTom Christiebefore adoption87b21b0

line 152why, one step back
152

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 154why, one step back
154

Truckin' onTom Christiebefore adoption6b60d95

lines 155–156why, one step back
155*A case-insensitive multi-dict.*
156

Added proxy exampleTom Christiebefore adoption87b21b0

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

Truckin' onTom Christiebefore adoption6b60d95

lines 158–161why, one step back
158>>> headers = Headers({'Content-Type': 'application/json'})
159>>> headers['content-type']160'application/json'161```

Added proxy exampleTom Christiebefore adoption87b21b0

line 162why, one step back
162

Truckin' onTom Christiebefore adoption6b60d95

line 163why, one step back
163___

Added proxy exampleTom Christiebefore adoption87b21b0

line 164why, one step back
164

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 166why, one step back
166

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 168why, one step back
168

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 170why, one step back
170

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 172why, one step back
172

Truckin' onTom Christiebefore adoption6b60d95

line 173why, one step back
173*TODO*

Added proxy exampleTom Christiebefore adoption87b21b0

line 174why, one step back
174

Truckin' onTom Christiebefore adoption6b60d95

line 175why, one step back
175---

Added proxy exampleTom Christiebefore adoption87b21b0

line 176why, one step back
176

Truckin' onTom Christiebefore adoption6b60d95

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

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 178why, one step back
178

Truckin' onTom Christiebefore adoption6b60d95

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

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 180why, one step back
180

Truckin' onTom Christiebefore adoption6b60d95

line 181why, one step back
181This 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 182why, one step back
182

Truckin' onTom Christiebefore adoption6b60d95

line 183why, one step back
183You 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 184why, one step back
184

Truckin' onTom Christiebefore adoption6b60d95

lines 185–192why, one step back
185* `RedirectAdapter` - Adds redirect support.
186* `EnvironmentAdapter` - Adds `.netrc` and envvars such as `REQUESTS_CA_BUNDLE`.187* `CookieAdapter` - Adds cookie persistence.188* `AuthAdapter` - Adds authentication support.189* `ConnectionPool` - Connection pooling & keep alive.190 * `HTTPConnection` - A single connection.191 * `HTTP11Connection` - A single HTTP/1.1 connection.192 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.