README.md
This file
Path
README.md
234 lines · 6.8 KiB · Markdown
Last changed by
Update README.mdTom Christiebefore adoptiond7f2478
History of this fileTake it
StuffTom Christiebefore adoption30530d4
lines 1–2why, one step back1# HTTPCore2Merge pull request #43 from encode/badgesTom Christiebefore adoption3553625
lines 3–12why, one step back3<a href="https://travis-ci.org/encode/httpcore">4 <img src="https://travis-ci.org/encode/httpcore.svg?branch=master" alt="Build Status">5</a>6<a href="https://codecov.io/gh/encode/httpcore">7 <img src="https://codecov.io/gh/encode/httpcore/branch/master/graph/badge.svg" alt="Coverage">8</a>9<a href="https://pypi.org/project/httpcore/">10 <img src="https://badge.fury.io/py/httpcore.svg" alt="Package version">11</a>12Truckin' onTom Christiebefore adoption6b60d95
line 13why, one step back13A proposal for [requests III](https://github.com/kennethreitz/requests3).Update READMETom Christiebefore adoption665743a
line 14why, one step back14Truckin' onTom Christiebefore adoption6b60d95
line 15why, one step back15## Feature supportUpdate READMETom Christiebefore adoption665743a
line 16why, one step back16Truckin' onTom Christiebefore adoption6b60d95
lines 17–19why, one step back17* `HTTP/1.1` and `HTTP/2` Support.18* `async`/`await` support for non-thread-blocking HTTP requests.19* Fully type annotated.Update README.mdTom Christiebefore adoptiond7f2478
line 20why, one step back20* 100% test coverage. *TODO - Almost there.*Update READMETom Christiebefore adoption665743a
line 21why, one step back21Truckin' onTom Christiebefore adoption6b60d95
line 22why, one step back22Plus all the standard features of requests...Update READMETom Christiebefore adoption665743a
line 23why, one step back23Truckin' onTom Christiebefore adoption6b60d95
lines 24–25why, one step back24* International Domains and URLs25* Keep-Alive & Connection PoolingUpdate READMETom Christiebefore adoptionfa8d296
line 26why, one step back26* Sessions with Cookie Persistence *TODO - Requires `adapters/cookies.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
line 27why, one step back27* Browser-style SSL VerificationUpdate READMETom Christiebefore adoptionfa8d296
line 28why, one step back28* Basic/Digest Authentication *TODO - Requires `adapters/authentication.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
lines 29–32why, one step back29* Elegant Key/Value Cookies *TODO*30* Automatic Decompression31* Automatic Content Decoding32* Unicode Response BodiesUpdate READMETom Christiebefore adoptionfa8d296
line 33why, one step back33* Multipart File Uploads *TODO - Request content currently supports bytes or async byte iterators.*Truckin' onTom Christiebefore adoption6b60d95
lines 34–36why, one step back34* HTTP(S) Proxy Support *TODO*35* Connection Timeouts36* Streaming DownloadsUpdate READMETom Christiebefore adoptionfa8d296
line 37why, one step back37* .netrc Support *TODO - Requires `adapters/environment.py` implementation.*Truckin' onTom Christiebefore adoption6b60d95
line 38why, one step back38* Chunked RequestsUpdate READMETom Christiebefore adoption665743a
line 39why, one step back39Update README.mdTom Christiebefore adoption0d3eb0e
line 40why, one step back40## UsageUpdate README.mdTom Christiebefore adoption01a3c09
line 41why, one step back41Update READMETom Christiebefore adoptionfa8d296
lines 42–43why, one step back42**Note**: Use `ipython` to try this from the console, since it supports `await`.43Update README.mdTom Christiebefore adoption337eb70
lines 44–45why, one step back44Making a request:45StuffTom Christiebefore adoption30530d4
line 46why, one step back46```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 47–48why, one step back47>>> import httpcore48>>> client = httpcore.Client()Still truckin' onTom Christiebefore adoption6cb5c0d
line 49why, one step back49>>> response = await client.get('https://example.com')Truckin' onTom Christiebefore adoption6b60d95
lines 50–51why, one step back50>>> response.status_code51<StatusCode.ok: 200>Still truckin' onTom Christiebefore adoption6cb5c0d
lines 52–53why, one step back52>>> response.protocol53'HTTP/2'Truckin' onTom Christiebefore adoption6b60d95
lines 54–55why, one step back54>>> 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 back58Alternatively, thread-synchronous requests:StuffTom Christiebefore adoption30530d4
lines 59–60why, one step back5960```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 61–62why, one step back61>>> import httpcore62>>> client = httpcore.SyncClient()Still truckin' onTom Christiebefore adoption6cb5c0d
line 63why, one step back63>>> response = client.get('https://example.com')Truckin' onTom Christiebefore adoption6b60d95
lines 64–65why, one step back64>>> response.status_code65<StatusCode.ok: 200>Still truckin' onTom Christiebefore adoption6cb5c0d
lines 66–67why, one step back66>>> response.protocol67'HTTP/2'Truckin' onTom Christiebefore adoption6b60d95
lines 68–69why, one step back68>>> response.text69'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'StuffTom Christiebefore adoption30530d4
lines 70–71why, one step back70```71Truckin' onTom Christiebefore adoption6b60d95
line 72why, one step back72---StuffTom Christiebefore adoption30530d4
line 73why, one step back73Update READMETom Christiebefore adoption4fe2f69
lines 74–87why, one step back74## Dependencies7576* `h11` - HTTP/1.1 support.77* `h2` - HTTP/2 support.78* `certifi` - SSL certificates.79* `chardet` - Fallback auto-detection for response encoding.80* `idna` - Internationalized domain name support.81* `rfc3986` - URL parsing & normalization.82* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*8384Additionally, credit is due to for `urllib3` for plenty of design inspiration.8586---87Truckin' onTom Christiebefore adoption6b60d95
line 88why, one step back88## API ReferenceUpdate READMETom Christiebefore adoption68b80dc
line 89why, one step back89Reorganise structureTom Christiebefore adoption0c6f618
line 90why, one step back90### `Client`Update READMETom Christiebefore adoption68b80dc
line 91why, one step back91Update READMETom Christiebefore adoption891548e
lines 92–98why, one step back92*An HTTP client, with connection pooling, redirects, cookie persistence, etc.*9394```python95>>> client = Client()96>>> response = await client.get('https://example.org')97```98Update READMETom Christiebefore adoption2de053e
line 99why, one step back99* `def __init__([ssl], [timeout], [pool_limits], [max_redirects])`Merge pull request #42 from encode/query-paramsTom Christiebefore adoption3de0425
lines 100–107why, one step back100* `async def .request(method, url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`101* `async def .get(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102* `async def .options(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103* `async def .head(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104* `async def .post(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105* `async def .put(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106* `async def .patch(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107* `async def .delete(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`Still truckin' onTom Christiebefore adoption6cb5c0d
line 108why, one step back108* `def .prepare_request(request)`Update READMETom Christiebefore adoption4fe2f69
line 109why, one step back109* `async def .send(request, [stream], [allow_redirects], [ssl], [timeout])`Still truckin' onTom Christiebefore adoption6cb5c0d
line 110why, one step back110* `async def .close()`Update README.mdTom Christiebefore adoption01a3c09
line 111why, one step back111Reorganise structureTom Christiebefore adoption0c6f618
line 112why, one step back112### `Response`README tweaksTom Christiebefore adoption8e1a263
line 113why, one step back113Update READMETom Christiebefore adoption4fe2f69
line 114why, one step back114*An HTTP response.*Still truckin' onTom Christiebefore adoption6cb5c0d
line 115why, one step back115Update READMETom Christiebefore adoption2de053e
line 116why, one step back116* `def __init__(...)`Truckin' onTom Christiebefore adoption6b60d95
lines 117–128why, one step back117* `.status_code` - **int**118* `.reason_phrase` - **str**119* `.protocol` - `"HTTP/2"` or `"HTTP/1.1"`120* `.url` - **URL**121* `.headers` - **Headers**122* `.content` - **bytes**123* `.text` - **str**124* `.encoding` - **str**125* `.is_redirect` - **bool**126* `.request` - **Request**127* `.cookies` - **Cookies** *TODO*128* `.history` - **List[Response]**Update README.mdTom Christiebefore adoption93d7ba3
line 129why, one step back129* `def .raise_for_status()` - **None**Update READMETom Christiebefore adoptionfa8d296
lines 130–136why, one step back130* `def .json()` - **Any** *TODO*131* `async def .read()` - **bytes**132* `async def .stream()` - **bytes iterator**133* `async def .raw()` - **bytes iterator**134* `async def .close()` - **None**135* `async def .next()` - **Response**136Reorganise structureTom Christiebefore adoption0c6f618
line 137why, one step back137### `Request`Truckin' onTom Christiebefore adoption6b60d95
line 138why, one step back138Still truckin' onTom Christiebefore adoption6cb5c0d
lines 139–142why, one step back139*An HTTP request. Can be constructed explicitly for more control over exactly140what gets sent over the wire.*141142```pythonUpdate READMETom Christiebefore adoption891548e
line 143why, one step back143>>> request = Request("GET", "https://example.org", headers={'host': 'example.org'})Still truckin' onTom Christiebefore adoption6cb5c0d
lines 144–146why, one step back144>>> response = await client.send(request)145```146Add query_params to URL and Request constructorsTom Christiebefore adoption6165459
line 147why, one step back147* `def __init__(method, url, query_params, content, headers)`Update READMETom Christiebefore adoptionfa8d296
lines 148–151why, one step back148* `.method` - **str** (Uppercased)149* `.url` - **URL**150* `.content` - **byte** or **byte async iterator**151* `.headers` - **Headers**Truckin' onTom Christiebefore adoption6b60d95
line 152why, one step back152Reorganise structureTom Christiebefore adoption0c6f618
line 153why, one step back153### `URL`Truckin' onTom Christiebefore adoption6b60d95
lines 154–155why, one step back154155*A normalized, IDNA supporting URL.*Update READMETom Christiebefore adoption891548e
lines 156–161why, one step back156157```python158>>> url = URL("https://example.org/")159>>> url.host160'example.org'161```Truckin' onTom Christiebefore adoption6b60d95
line 162why, one step back162Add query_params to URL and Request constructorsTom Christiebefore adoption6165459
line 163why, one step back163* `def __init__(url, allow_relative=False, query_params=None)`Truckin' onTom Christiebefore adoption6b60d95
lines 164–175why, one step back164* `.scheme` - **str**165* `.authority` - **str**166* `.host` - **str**167* `.port` - **int**168* `.path` - **str**169* `.query` - **str**170* `.full_path` - **str**171* `.fragment` - **str**172* `.is_ssl` - **bool**173* `.origin` - **Origin**174* `.is_absolute_url` - **bool**175* `.is_relative_url` - **bool**Update READMETom Christiebefore adoptionfa8d296
lines 176–177why, one step back176* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**177* `def .resolve_with(url)` - **URL**Truckin' onTom Christiebefore adoption6b60d95
line 178why, one step back178Reorganise structureTom Christiebefore adoption0c6f618
line 179why, one step back179### `Origin`Truckin' onTom Christiebefore adoption6b60d95
lines 180–182why, one step back180181*A normalized, IDNA supporting set of scheme/host/port info.*182Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 183why, one step back183```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 184–185why, one step back184>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')185TrueREADME tweaksTom Christiebefore adoption8e1a263
lines 186–187why, one step back186```187Update READMETom Christiebefore adoption2de053e
line 188why, one step back188* `def __init__(url)`Truckin' onTom Christiebefore adoption6b60d95
lines 189–191why, one step back189* `.is_ssl` - **bool**190* `.host` - **str**191* `.port` - **int**Added proxy exampleTom Christiebefore adoption87b21b0
line 192why, one step back192Reorganise structureTom Christiebefore adoption0c6f618
line 193why, one step back193### `Headers`Added proxy exampleTom Christiebefore adoption87b21b0
line 194why, one step back194Truckin' onTom Christiebefore adoption6b60d95
lines 195–196why, one step back195*A case-insensitive multi-dict.*196Added proxy exampleTom Christiebefore adoption87b21b0
line 197why, one step back197```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 198–201why, one step back198>>> headers = Headers({'Content-Type': 'application/json'})199>>> headers['content-type']200'application/json'201```Update READMETom Christiebefore adoption2de053e
lines 202–203why, one step back202203* `def __init__(headers)`Added proxy exampleTom Christiebefore adoption87b21b0
line 204why, one step back204Truckin' onTom Christiebefore adoption6b60d95
line 205why, one step back205___Added proxy exampleTom Christiebefore adoption87b21b0
line 206why, one step back206Truckin' onTom Christiebefore adoption6b60d95
line 207why, one step back207## Alternate backendsAdded proxy exampleTom Christiebefore adoption87b21b0
line 208why, one step back208Truckin' onTom Christiebefore adoption6b60d95
line 209why, one step back209### `SyncClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 210why, one step back210Truckin' onTom Christiebefore adoption6b60d95
line 211why, one step back211A thread-synchronous client.Added proxy exampleTom Christiebefore adoption87b21b0
line 212why, one step back212Truckin' onTom Christiebefore adoption6b60d95
line 213why, one step back213### `TrioClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 214why, one step back214Truckin' onTom Christiebefore adoption6b60d95
line 215why, one step back215*TODO*Added proxy exampleTom Christiebefore adoption87b21b0
line 216why, one step back216Truckin' onTom Christiebefore adoption6b60d95
line 217why, one step back217---Added proxy exampleTom Christiebefore adoption87b21b0
line 218why, one step back218Truckin' onTom Christiebefore adoption6b60d95
line 219why, one step back219## The StackImprove GatewayService exampleTom Christiebefore adoption9d59a5a
line 220why, one step back220Truckin' onTom Christiebefore adoption6b60d95
line 221why, one step back221The `httpcore` client builds up behavior in a modular way.Improve GatewayService exampleTom Christiebefore adoption9d59a5a
line 222why, one step back222Truckin' onTom Christiebefore adoption6b60d95
line 223why, one step back223This 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 224why, one step back224Truckin' onTom Christiebefore adoption6b60d95
line 225why, one step back225You 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 226why, one step back226Truckin' onTom Christiebefore adoption6b60d95
lines 227–234why, one step back227* `RedirectAdapter` - Adds redirect support.228* `EnvironmentAdapter` - Adds `.netrc` and envvars such as `REQUESTS_CA_BUNDLE`.229* `CookieAdapter` - Adds cookie persistence.230* `AuthAdapter` - Adds authentication support.231* `ConnectionPool` - Connection pooling & keep alive.232 * `HTTPConnection` - A single connection.233 * `HTTP11Connection` - A single HTTP/1.1 connection.234 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.