Skip to content
Myr

README.md

This file

Path

README.md

184 lines · 4.6 KiB · Markdown

Last changed by

Update READMETom Christiebefore adoptionfa8d296

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–43why, one step back
37>>> import httpcore
38>>> client = httpcore.Client()39>>> response = await client.get('http://example.com')40>>> response.status_code41<StatusCode.ok: 200>42>>> response.text43'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'

StuffTom Christiebefore adoption30530d4

lines 44–45why, one step back
44```
45

Truckin' onTom Christiebefore adoption6b60d95

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

StuffTom Christiebefore adoption30530d4

lines 47–48why, one step back
47
48```python

Truckin' onTom Christiebefore adoption6b60d95

lines 49–55why, one step back
49>>> import httpcore
50>>> client = httpcore.SyncClient()51>>> response = client.get('http://example.com')52>>> response.status_code53<StatusCode.ok: 200>54>>> response.text55'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'

StuffTom Christiebefore adoption30530d4

lines 56–57why, one step back
56```
57

Truckin' onTom Christiebefore adoption6b60d95

line 58why, one step back
58---

StuffTom Christiebefore adoption30530d4

line 59why, one step back
59

Truckin' onTom Christiebefore adoption6b60d95

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

Update READMETom Christiebefore adoption68b80dc

line 61why, one step back
61

Truckin' onTom Christiebefore adoption6b60d95

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

Update READMETom Christiebefore adoption68b80dc

line 63why, one step back
63

Truckin' onTom Christiebefore adoption6b60d95

lines 64–74why, one step back
64* `.request(method, url, ...)`
65* `.get(url, ...)`66* `.options(url, ...)`67* `.head(url, ...)`68* `.post(url, ...)`69* `.put(url, ...)`70* `.patch(url, ...)`71* `.delete(url, ...)`72* `.prepare_request(request)`73* `.send(request, ...)`74* `.close()`

Update README.mdTom Christiebefore adoption01a3c09

line 75why, one step back
75

Truckin' onTom Christiebefore adoption6b60d95

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

README tweaksTom Christiebefore adoption8e1a263

line 77why, one step back
77

Truckin' onTom Christiebefore adoption6b60d95

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

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 79why, one step back
79

Truckin' onTom Christiebefore adoption6b60d95

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

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

line 92why, one step back
92

Update READMETom Christiebefore adoptionfa8d296

lines 93–102why, one step back
93Methods:
9495* `def .raise_for_status()` - **Response** *TODO*96* `def .json()` - **Any** *TODO*97* `async def .read()` - **bytes**98* `async def .stream()` - **bytes iterator**99* `async def .raw()` - **bytes iterator**100* `async def .close()` - **None**101* `async def .next()` - **Response**102

Truckin' onTom Christiebefore adoption6b60d95

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

Update READMETom Christiebefore adoptionfa8d296

lines 105–108why, one step back
105* `.method` - **str** (Uppercased)
106* `.url` - **URL**107* `.content` - **byte** or **byte async iterator**108* `.headers` - **Headers**

Truckin' onTom Christiebefore adoption6b60d95

lines 109–125why, one step back
109
110#### `URL(url, allow_relative=False)`111112*A normalized, IDNA supporting URL.*113114* `.scheme` - **str**115* `.authority` - **str**116* `.host` - **str**117* `.port` - **int**118* `.path` - **str**119* `.query` - **str**120* `.full_path` - **str**121* `.fragment` - **str**122* `.is_ssl` - **bool**123* `.origin` - **Origin**124* `.is_absolute_url` - **bool**125* `.is_relative_url` - **bool**

Update READMETom Christiebefore adoptionfa8d296

lines 126–130why, one step back
126
127Methods:128129* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**130* `def .resolve_with(url)` - **URL**

Truckin' onTom Christiebefore adoption6b60d95

lines 131–135why, one step back
131
132#### `Origin(url)`133134*A normalized, IDNA supporting set of scheme/host/port info.*135

Update README for 0.2.0Tom Christiebefore adoptionbb3d452

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

Truckin' onTom Christiebefore adoption6b60d95

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

README tweaksTom Christiebefore adoption8e1a263

lines 139–140why, one step back
139```
140

Truckin' onTom Christiebefore adoption6b60d95

lines 141–143why, one step back
141* `.is_ssl` - **bool**
142* `.host` - **str**143* `.port` - **int**

Added proxy exampleTom Christiebefore adoption87b21b0

line 144why, one step back
144

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 146why, one step back
146

Truckin' onTom Christiebefore adoption6b60d95

lines 147–148why, one step back
147*A case-insensitive multi-dict.*
148

Added proxy exampleTom Christiebefore adoption87b21b0

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

Truckin' onTom Christiebefore adoption6b60d95

lines 150–153why, one step back
150>>> headers = Headers({'Content-Type': 'application/json'})
151>>> headers['content-type']152'application/json'153```

Added proxy exampleTom Christiebefore adoption87b21b0

line 154why, one step back
154

Truckin' onTom Christiebefore adoption6b60d95

line 155why, one step back
155___

Added proxy exampleTom Christiebefore adoption87b21b0

line 156why, one step back
156

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 158why, one step back
158

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 160why, one step back
160

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 162why, one step back
162

Truckin' onTom Christiebefore adoption6b60d95

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

Added proxy exampleTom Christiebefore adoption87b21b0

line 164why, one step back
164

Truckin' onTom Christiebefore adoption6b60d95

line 165why, one step back
165*TODO*

Added proxy exampleTom Christiebefore adoption87b21b0

line 166why, one step back
166

Truckin' onTom Christiebefore adoption6b60d95

line 167why, one step back
167---

Added proxy exampleTom Christiebefore adoption87b21b0

line 168why, one step back
168

Truckin' onTom Christiebefore adoption6b60d95

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

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 170why, one step back
170

Truckin' onTom Christiebefore adoption6b60d95

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

Improve GatewayService exampleTom Christiebefore adoption9d59a5a

line 172why, one step back
172

Truckin' onTom Christiebefore adoption6b60d95

line 173why, one step back
173This 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 174why, one step back
174

Truckin' onTom Christiebefore adoption6b60d95

line 175why, one step back
175You 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 176why, one step back
176

Truckin' onTom Christiebefore adoption6b60d95

lines 177–184why, one step back
177* `RedirectAdapter` - Adds redirect support.
178* `EnvironmentAdapter` - Adds `.netrc` and envvars such as `REQUESTS_CA_BUNDLE`.179* `CookieAdapter` - Adds cookie persistence.180* `AuthAdapter` - Adds authentication support.181* `ConnectionPool` - Connection pooling & keep alive.182 * `HTTPConnection` - A single connection.183 * `HTTP11Connection` - A single HTTP/1.1 connection.184 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.