README.md
This file
Path
README.md
184 lines · 4.6 KiB · Markdown
Last changed by
Update READMETom Christiebefore adoptionfa8d296
History of this fileTake it
StuffTom Christiebefore adoption30530d4
lines 1–2why, one step back1# HTTPCore2Truckin' onTom Christiebefore adoption6b60d95
line 3why, one step back3A proposal for [requests III](https://github.com/kennethreitz/requests3).Update READMETom Christiebefore adoption665743a
line 4why, one step back4Truckin' onTom Christiebefore adoption6b60d95
line 5why, one step back5## Feature supportUpdate READMETom Christiebefore adoption665743a
line 6why, one step back6Truckin' onTom Christiebefore adoption6b60d95
lines 7–10why, one step back7* `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 back11Truckin' onTom Christiebefore adoption6b60d95
line 12why, one step back12Plus all the standard features of requests...Update READMETom Christiebefore adoption665743a
line 13why, one step back13Truckin' onTom Christiebefore adoption6b60d95
lines 14–15why, one step back14* International Domains and URLs15* Keep-Alive & Connection PoolingUpdate READMETom Christiebefore adoptionfa8d296
line 16why, one step back16* Sessions with Cookie Persistence *TODO - Requires `adapters/cookies.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
line 17why, one step back17* Browser-style SSL VerificationUpdate READMETom Christiebefore adoptionfa8d296
line 18why, one step back18* Basic/Digest Authentication *TODO - Requires `adapters/authentication.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
lines 19–22why, one step back19* Elegant Key/Value Cookies *TODO*20* Automatic Decompression21* Automatic Content Decoding22* Unicode Response BodiesUpdate READMETom Christiebefore adoptionfa8d296
line 23why, one step back23* Multipart File Uploads *TODO - Request content currently supports bytes or async byte iterators.*Truckin' onTom Christiebefore adoption6b60d95
lines 24–26why, one step back24* HTTP(S) Proxy Support *TODO*25* Connection Timeouts26* Streaming DownloadsUpdate READMETom Christiebefore adoptionfa8d296
line 27why, one step back27* .netrc Support *TODO - Requires `adapters/environment.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
line 28why, one step back28* Chunked RequestsUpdate READMETom Christiebefore adoption665743a
line 29why, one step back29Update README.mdTom Christiebefore adoption0d3eb0e
line 30why, one step back30## UsageUpdate README.mdTom Christiebefore adoption01a3c09
line 31why, one step back31Update READMETom Christiebefore adoptionfa8d296
lines 32–33why, one step back32**Note**: Use `ipython` to try this from the console, since it supports `await`.33Update README.mdTom Christiebefore adoption337eb70
lines 34–35why, one step back34Making a request:35StuffTom Christiebefore adoption30530d4
line 36why, one step back36```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 37–43why, one step back37>>> import httpcore38>>> 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 back44```45Truckin' onTom Christiebefore adoption6b60d95
line 46why, one step back46Alternatively, thread-synchronous requests:StuffTom Christiebefore adoption30530d4
lines 47–48why, one step back4748```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 49–55why, one step back49>>> import httpcore50>>> 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 back56```57Truckin' onTom Christiebefore adoption6b60d95
line 58why, one step back58---StuffTom Christiebefore adoption30530d4
line 59why, one step back59Truckin' onTom Christiebefore adoption6b60d95
line 60why, one step back60## API ReferenceUpdate READMETom Christiebefore adoption68b80dc
line 61why, one step back61Truckin' onTom Christiebefore adoption6b60d95
line 62why, one step back62#### `Client([ssl], [timeout], [pool_limits], [max_redirects])`Update READMETom Christiebefore adoption68b80dc
line 63why, one step back63Truckin' onTom Christiebefore adoption6b60d95
lines 64–74why, one step back64* `.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 back75Truckin' onTom Christiebefore adoption6b60d95
line 76why, one step back76### ModelsREADME tweaksTom Christiebefore adoption8e1a263
line 77why, one step back77Truckin' onTom Christiebefore adoption6b60d95
line 78why, one step back78#### `Response(...)`Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 79why, one step back79Truckin' onTom Christiebefore adoption6b60d95
lines 80–91why, one step back80* `.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 back92Update READMETom Christiebefore adoptionfa8d296
lines 93–102why, one step back93Methods: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**102Truckin' onTom Christiebefore adoption6b60d95
lines 103–104why, one step back103#### `Request(method, url, content, headers)`104Update READMETom Christiebefore adoptionfa8d296
lines 105–108why, one step back105* `.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 back109110#### `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 back126127Methods: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 back131132#### `Origin(url)`133134*A normalized, IDNA supporting set of scheme/host/port info.*135Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 136why, one step back136```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 137–138why, one step back137>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')138TrueREADME tweaksTom Christiebefore adoption8e1a263
lines 139–140why, one step back139```140Truckin' onTom Christiebefore adoption6b60d95
lines 141–143why, one step back141* `.is_ssl` - **bool**142* `.host` - **str**143* `.port` - **int**Added proxy exampleTom Christiebefore adoption87b21b0
line 144why, one step back144Truckin' onTom Christiebefore adoption6b60d95
line 145why, one step back145#### `Headers(headers)`Added proxy exampleTom Christiebefore adoption87b21b0
line 146why, one step back146Truckin' onTom Christiebefore adoption6b60d95
lines 147–148why, one step back147*A case-insensitive multi-dict.*148Added proxy exampleTom Christiebefore adoption87b21b0
line 149why, one step back149```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 150–153why, one step back150>>> headers = Headers({'Content-Type': 'application/json'})151>>> headers['content-type']152'application/json'153```Added proxy exampleTom Christiebefore adoption87b21b0
line 154why, one step back154Truckin' onTom Christiebefore adoption6b60d95
line 155why, one step back155___Added proxy exampleTom Christiebefore adoption87b21b0
line 156why, one step back156Truckin' onTom Christiebefore adoption6b60d95
line 157why, one step back157## Alternate backendsAdded proxy exampleTom Christiebefore adoption87b21b0
line 158why, one step back158Truckin' onTom Christiebefore adoption6b60d95
line 159why, one step back159### `SyncClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 160why, one step back160Truckin' onTom Christiebefore adoption6b60d95
line 161why, one step back161A thread-synchronous client.Added proxy exampleTom Christiebefore adoption87b21b0
line 162why, one step back162Truckin' onTom Christiebefore adoption6b60d95
line 163why, one step back163### `TrioClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 164why, one step back164Truckin' onTom Christiebefore adoption6b60d95
line 165why, one step back165*TODO*Added proxy exampleTom Christiebefore adoption87b21b0
line 166why, one step back166Truckin' onTom Christiebefore adoption6b60d95
line 167why, one step back167---Added proxy exampleTom Christiebefore adoption87b21b0
line 168why, one step back168Truckin' onTom Christiebefore adoption6b60d95
line 169why, one step back169## The StackImprove GatewayService exampleTom Christiebefore adoption9d59a5a
line 170why, one step back170Truckin' onTom Christiebefore adoption6b60d95
line 171why, one step back171The `httpcore` client builds up behavior in a modular way.Improve GatewayService exampleTom Christiebefore adoption9d59a5a
line 172why, one step back172Truckin' onTom Christiebefore adoption6b60d95
line 173why, one step back173This 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 back174Truckin' onTom Christiebefore adoption6b60d95
line 175why, one step back175You 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 back176Truckin' onTom Christiebefore adoption6b60d95
lines 177–184why, one step back177* `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.