README.md
This file
Path
README.md
230 lines · 6.3 KiB · Markdown
Last changed by
Minor README tweakTom Christiebefore adoption813bb7c
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 back13## Feature supportUpdate READMETom Christiebefore adoption665743a
line 14why, one step back14Truckin' onTom Christiebefore adoption6b60d95
line 15why, one step back15* `HTTP/1.1` and `HTTP/2` Support.Merge pull request #58 from encode/sync-by-defaultTom Christiebefore adoptionb6c27f0
lines 16–17why, one step back16* `async`/`await` support for non-blocking HTTP requests.17* Strict timeouts everywhere by default.Truckin' onTom Christiebefore adoption6b60d95
line 18why, one step back18* Fully type annotated.Update README.mdTom Christiebefore adoptiond7f2478
line 19why, one step back19* 100% test coverage. *TODO - Almost there.*Update READMETom Christiebefore adoption665743a
line 20why, one step back20Truckin' onTom Christiebefore adoption6b60d95
line 21why, one step back21Plus all the standard features of requests...Update READMETom Christiebefore adoption665743a
line 22why, one step back22Truckin' onTom Christiebefore adoption6b60d95
lines 23–24why, one step back23* International Domains and URLs24* Keep-Alive & Connection PoolingUpdate READMETom Christiebefore adoption58461d4
line 25why, one step back25* Sessions with Cookie Persistence *TODO*Truckin' onTom Christiebefore adoption6b60d95
line 26why, one step back26* Browser-style SSL VerificationUpdate READMETom Christiebefore adoption58461d4
line 27why, one step back27* Basic/Digest Authentication *TODO*Truckin' onTom Christiebefore adoption6b60d95
lines 28–31why, one step back28* Elegant Key/Value Cookies *TODO*29* Automatic Decompression30* Automatic Content Decoding31* Unicode Response BodiesUpdate README.mdTom Christiebefore adoption3408d7b
line 32why, one step back32* Multipart File Uploads *TODO - Request content currently supports URL encoded data, bytes, or async byte iterators.*Truckin' onTom Christiebefore adoption6b60d95
lines 33–35why, one step back33* HTTP(S) Proxy Support *TODO*34* Connection Timeouts35* Streaming DownloadsUpdate READMETom Christiebefore adoption58461d4
line 36why, one step back36* .netrc Support *TODO*Truckin' onTom Christiebefore adoption6b60d95
line 37why, one step back37* Chunked RequestsUpdate READMETom Christiebefore adoption665743a
line 38why, one step back38Update README.mdTom Christiebefore adoption0d3eb0e
line 39why, one step back39## UsageUpdate README.mdTom Christiebefore adoption01a3c09
line 40why, one step back40Update README.mdTom Christiebefore adoption337eb70
lines 41–42why, one step back41Making a request:42StuffTom Christiebefore adoption30530d4
line 43why, one step back43```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 44–45why, one step back44>>> import httpcore45>>> client = httpcore.Client()Update READMETom Christiebefore adoption58461d4
line 46why, one step back46>>> response = client.get('https://example.com')Truckin' onTom Christiebefore adoption6b60d95
line 47why, one step back47>>> response.status_codeMinor README tweakTom Christiebefore adoption813bb7c
line 48why, one step back48<HTTPStatus.OK: 200>Still truckin' onTom Christiebefore adoption6cb5c0d
lines 49–50why, one step back49>>> response.protocol50'HTTP/2'Truckin' onTom Christiebefore adoption6b60d95
lines 51–52why, one step back51>>> response.text52'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'StuffTom Christiebefore adoption30530d4
lines 53–54why, one step back53```54Update READMETom Christiebefore adoption58461d4
line 55why, one step back55Alternatively, async requests:StuffTom Christiebefore adoption30530d4
line 56why, one step back56Update READMETom Christiebefore adoption58461d4
lines 57–58why, one step back57**Note**: Use `ipython` to try this from the console, since it supports `await`.58StuffTom Christiebefore adoption30530d4
line 59why, one step back59```pythonTruckin' onTom Christiebefore adoption6b60d95
line 60why, one step back60>>> import httpcoreUpdate READMETom Christiebefore adoption58461d4
lines 61–62why, one step back61>>> client = httpcore.AsyncClient()62>>> response = await client.get('https://example.com')Truckin' onTom Christiebefore adoption6b60d95
line 63why, one step back63>>> response.status_codeMinor README tweakTom Christiebefore adoption813bb7c
line 64why, one step back64<HTTPStatus.OK: 200>Still truckin' onTom Christiebefore adoption6cb5c0d
lines 65–66why, one step back65>>> response.protocol66'HTTP/2'Truckin' onTom Christiebefore adoption6b60d95
lines 67–68why, one step back67>>> response.text68'<!doctype html>\n<html>\n<head>\n<title>Example Domain</title>\n...'StuffTom Christiebefore adoption30530d4
lines 69–70why, one step back69```70Truckin' onTom Christiebefore adoption6b60d95
line 71why, one step back71---StuffTom Christiebefore adoption30530d4
line 72why, one step back72Update READMETom Christiebefore adoption4fe2f69
lines 73–82why, one step back73## Dependencies7475* `h11` - HTTP/1.1 support.76* `h2` - HTTP/2 support.77* `certifi` - SSL certificates.78* `chardet` - Fallback auto-detection for response encoding.79* `idna` - Internationalized domain name support.80* `rfc3986` - URL parsing & normalization.81* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*82Update READMETom Christiebefore adoption58461d4
line 83why, one step back83A huge amount of credit is due to `requests` for the API layout thatUpdate README.mdTom Christiebefore adoption84b9691
lines 84–85why, one step back84much of this work follows, as well as to `urllib3` for plenty of design85inspiration around the lower level networking details.Update READMETom Christiebefore adoption4fe2f69
lines 86–88why, one step back8687---88Truckin' onTom Christiebefore adoption6b60d95
line 89why, one step back89## API ReferenceUpdate READMETom Christiebefore adoption68b80dc
line 90why, one step back90Reorganise structureTom Christiebefore adoption0c6f618
line 91why, one step back91### `Client`Update READMETom Christiebefore adoption68b80dc
line 92why, one step back92Update READMETom Christiebefore adoption891548e
lines 93–96why, one step back93*An HTTP client, with connection pooling, redirects, cookie persistence, etc.*9495```python96>>> client = Client()Update READMETom Christiebefore adoption441a1f6
line 97why, one step back97>>> response = client.get('https://example.org')Update READMETom Christiebefore adoption891548e
lines 98–99why, one step back98```99Update READMETom Christiebefore adoption58461d4
lines 100–108why, one step back100* `def __init__([ssl], [timeout], [pool_limits], [max_redirects], [dispatch])`101* `def .request(method, url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`102* `def .get(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`103* `def .options(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`104* `def .head(url, [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`105* `def .post(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`106* `def .put(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`107* `def .patch(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`108* `def .delete(url, [content], [query_params], [headers], [stream], [allow_redirects], [ssl], [timeout])`Still truckin' onTom Christiebefore adoption6cb5c0d
line 109why, one step back109* `def .prepare_request(request)`Update READMETom Christiebefore adoption58461d4
lines 110–111why, one step back110* `def .send(request, [stream], [allow_redirects], [ssl], [timeout])`111* `def .close()`Update README.mdTom Christiebefore adoption01a3c09
line 112why, one step back112Reorganise structureTom Christiebefore adoption0c6f618
line 113why, one step back113### `Response`README tweaksTom Christiebefore adoption8e1a263
line 114why, one step back114Update READMETom Christiebefore adoption4fe2f69
line 115why, one step back115*An HTTP response.*Still truckin' onTom Christiebefore adoption6cb5c0d
line 116why, one step back116Update READMETom Christiebefore adoption2de053e
line 117why, one step back117* `def __init__(...)`Truckin' onTom Christiebefore adoption6b60d95
lines 118–129why, one step back118* `.status_code` - **int**119* `.reason_phrase` - **str**120* `.protocol` - `"HTTP/2"` or `"HTTP/1.1"`121* `.url` - **URL**122* `.headers` - **Headers**123* `.content` - **bytes**124* `.text` - **str**125* `.encoding` - **str**126* `.is_redirect` - **bool**127* `.request` - **Request**128* `.cookies` - **Cookies** *TODO*129* `.history` - **List[Response]**Update README.mdTom Christiebefore adoption93d7ba3
line 130why, one step back130* `def .raise_for_status()` - **None**Update READMETom Christiebefore adoptionfa8d296
line 131why, one step back131* `def .json()` - **Any** *TODO*Update READMETom Christiebefore adoption58461d4
lines 132–136why, one step back132* `def .read()` - **bytes**133* `def .stream()` - **bytes iterator**134* `def .raw()` - **bytes iterator**135* `def .close()` - **None**136* `def .next()` - **Response**Update READMETom Christiebefore adoptionfa8d296
line 137why, one step back137Reorganise structureTom Christiebefore adoption0c6f618
line 138why, one step back138### `Request`Truckin' onTom Christiebefore adoption6b60d95
line 139why, one step back139Still truckin' onTom Christiebefore adoption6cb5c0d
lines 140–143why, one step back140*An HTTP request. Can be constructed explicitly for more control over exactly141what gets sent over the wire.*142143```pythonUpdate READMETom Christiebefore adoption891548e
line 144why, one step back144>>> request = Request("GET", "https://example.org", headers={'host': 'example.org'})Update READMETom Christiebefore adoptiona5eb829
line 145why, one step back145>>> response = client.send(request)Still truckin' onTom Christiebefore adoption6cb5c0d
lines 146–147why, one step back146```147Add query_params to URL and Request constructorsTom Christiebefore adoption6165459
line 148why, one step back148* `def __init__(method, url, query_params, content, headers)`Update READMETom Christiebefore adoptionfa8d296
lines 149–152why, one step back149* `.method` - **str** (Uppercased)150* `.url` - **URL**151* `.content` - **byte** or **byte async iterator**152* `.headers` - **Headers**Truckin' onTom Christiebefore adoption6b60d95
line 153why, one step back153Reorganise structureTom Christiebefore adoption0c6f618
line 154why, one step back154### `URL`Truckin' onTom Christiebefore adoption6b60d95
lines 155–156why, one step back155156*A normalized, IDNA supporting URL.*Update READMETom Christiebefore adoption891548e
lines 157–162why, one step back157158```python159>>> url = URL("https://example.org/")160>>> url.host161'example.org'162```Truckin' onTom Christiebefore adoption6b60d95
line 163why, one step back163Add query_params to URL and Request constructorsTom Christiebefore adoption6165459
line 164why, one step back164* `def __init__(url, allow_relative=False, query_params=None)`Truckin' onTom Christiebefore adoption6b60d95
lines 165–176why, one step back165* `.scheme` - **str**166* `.authority` - **str**167* `.host` - **str**168* `.port` - **int**169* `.path` - **str**170* `.query` - **str**171* `.full_path` - **str**172* `.fragment` - **str**173* `.is_ssl` - **bool**174* `.origin` - **Origin**175* `.is_absolute_url` - **bool**176* `.is_relative_url` - **bool**Update READMETom Christiebefore adoptionfa8d296
lines 177–178why, one step back177* `def .copy_with([scheme], [authority], [path], [query], [fragment])` - **URL**178* `def .resolve_with(url)` - **URL**Truckin' onTom Christiebefore adoption6b60d95
line 179why, one step back179Reorganise structureTom Christiebefore adoption0c6f618
line 180why, one step back180### `Origin`Truckin' onTom Christiebefore adoption6b60d95
lines 181–183why, one step back181182*A normalized, IDNA supporting set of scheme/host/port info.*183Update README for 0.2.0Tom Christiebefore adoptionbb3d452
line 184why, one step back184```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 185–186why, one step back185>>> Origin('https://example.org') == Origin('HTTPS://EXAMPLE.ORG:443')186TrueREADME tweaksTom Christiebefore adoption8e1a263
lines 187–188why, one step back187```188Update READMETom Christiebefore adoption2de053e
line 189why, one step back189* `def __init__(url)`Truckin' onTom Christiebefore adoption6b60d95
lines 190–192why, one step back190* `.is_ssl` - **bool**191* `.host` - **str**192* `.port` - **int**Added proxy exampleTom Christiebefore adoption87b21b0
line 193why, one step back193Reorganise structureTom Christiebefore adoption0c6f618
line 194why, one step back194### `Headers`Added proxy exampleTom Christiebefore adoption87b21b0
line 195why, one step back195Truckin' onTom Christiebefore adoption6b60d95
lines 196–197why, one step back196*A case-insensitive multi-dict.*197Added proxy exampleTom Christiebefore adoption87b21b0
line 198why, one step back198```pythonTruckin' onTom Christiebefore adoption6b60d95
lines 199–202why, one step back199>>> headers = Headers({'Content-Type': 'application/json'})200>>> headers['content-type']201'application/json'202```Update READMETom Christiebefore adoption2de053e
lines 203–204why, one step back203204* `def __init__(headers)`Added proxy exampleTom Christiebefore adoption87b21b0
line 205why, one step back205Truckin' onTom Christiebefore adoption6b60d95
line 206why, one step back206___Added proxy exampleTom Christiebefore adoption87b21b0
line 207why, one step back207Truckin' onTom Christiebefore adoption6b60d95
line 208why, one step back208## Alternate backendsAdded proxy exampleTom Christiebefore adoption87b21b0
line 209why, one step back209Update READMETom Christiebefore adoption58461d4
line 210why, one step back210### `AsyncClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 211why, one step back211Update READMETom Christiebefore adoption58461d4
line 212why, one step back212An asyncio client.Added proxy exampleTom Christiebefore adoption87b21b0
line 213why, one step back213Truckin' onTom Christiebefore adoption6b60d95
line 214why, one step back214### `TrioClient`Added proxy exampleTom Christiebefore adoption87b21b0
line 215why, one step back215Truckin' onTom Christiebefore adoption6b60d95
line 216why, one step back216*TODO*Added proxy exampleTom Christiebefore adoption87b21b0
line 217why, one step back217Truckin' onTom Christiebefore adoption6b60d95
line 218why, one step back218---Added proxy exampleTom Christiebefore adoption87b21b0
line 219why, one step back219Truckin' onTom Christiebefore adoption6b60d95
line 220why, one step back220## The StackImprove GatewayService exampleTom Christiebefore adoption9d59a5a
line 221why, one step back221Update READMETom Christiebefore adoption58461d4
lines 222–224why, one step back222There are two main layers in the stack. The client handles redirection,223cookie persistence (TODO), and authentication (TODO). The dispatcher224handles sending the actual request and getting the response.Improve GatewayService exampleTom Christiebefore adoption9d59a5a
line 225why, one step back225Update READMETom Christiebefore adoption58461d4
lines 226–227why, one step back226* `Client` - Redirect, authentication, cookies etc.227* `ConnectionPool(Dispatcher)` - Connection pooling & keep alive.Truckin' onTom Christiebefore adoption6b60d95
lines 228–230why, one step back228 * `HTTPConnection` - A single connection.229 * `HTTP11Connection` - A single HTTP/1.1 connection.230 * `HTTP2Connection` - A single HTTP/2 connection, with multiple streams.