README.md
This file
Path
README.md
82 lines · 4.2 KiB · Markdown
Last changed by
Update READMETom Christiebefore adoption04ec665
History of this fileTake it
StuffTom Christiebefore adoption30530d4
lines 1–41why, one step back1# HTTPCore23I started to dive into implementation and API design here.45I know this isn't what you were suggesting with `requests-core`, but it'd be6worth you taking a slow look at this and seeing if there's anything that you7think is a no-go.89`httpcore` provides the same proposed *functionality* as requests-core, but at a slightly10lower abstraction level.1112Rather than returning `Response` models, it returns the minimal possible13interface. There's no `response.text` or any other cleverness, `response.headers`14are plain byte-pair lists, rather than a headers datastructure etc...1516**The proposal here is that `httpcore` would be a silent-partner dependency of `requests3`,17taking the place of the existing `urllib3` dependency.**1819---2021The benefits to my mind of this level of abstraction are that it is as22agnostic as possible to whatever request/response models are built on top23of it, and exposes only plain datastructures that reflect the network response.2425* An `encode/httpcore` package would be something I'd gladly maintain. The naming26 makes sense to me, as there's no strictly implied relationship to `requests`,27 although it would fulfil all the requirements for `requests3` to build on,28 and would have a strict semver policy.29* An `encode/httpcore` package is something that would play in well to the30 collaboratively sponsored OSS story that Encode is pitching. It'd provide what31 you need for `requests3` without encroaching on the `requests` brand.32 We'd position it similarly to how `urllib3` is positioned to `requests` now.33 A focused, low-level networking library, that `requests` then builds the34 developer-focused API on top of.35* The current implementation includes all the async API points.36 The `PoolManger.request()` and `PoolManager.close()` methods are currently37 stubbed-out. All the remaining implementation hangs off of those two points.38* Take a quick look over the test cases or the package itself to get a feel39 for it. It's all type annotated, and should be easy to find your way around.40* I've not yet added corresponding sync API points to the implementation, but41 they will come.Update READMETom Christiebefore adoptiona940798
line 42why, one step back42* There's [a chunk of implmentation work towards connection pooling in `requests-async`](https://github.com/encode/requests-async/blob/5ec2aa80bd4499997fa744f3be19a0bdeccbaeed/requests_async/connections.py). I've not had enough time to nail it yet, but it's got the broad brush-strokes, and given me enough to get a rough feel for how much work there is to do.StuffTom Christiebefore adoption30530d4
lines 43–46why, one step back43* We would absolutely want to implement HTTP/2 support.44* Trio support is something that could *potentially* come later, but it needs to45 be a secondary consideration.46* I think all the functionality required is stubbed out in the API, with two exceptions.Update READMETom Christiebefore adoption04ec665
lines 47–48why, one step back47 (1) I've not yet added any proxy configuration API. Haven't looked into that enough48 yet. (2) I've not yet added any retry configuration API, since I havn't reallyStuffTom Christiebefore adoption30530d4
lines 49–82why, one step back49 looked enough into which side of requests vs. urllib3 that sits on, or exactly how50 urllib3 tackles retries, etc.51* I'd be planning to prioritize working on this from Mon 15th April. I don't think52 it'd take too long to get it to a feature complete and API stable state.53 (With the exception of the later HTTP/2 work, which I can't really assess yet.)54 I probably don't have any time left before then - need to focus on what I'm55 delivering to DjangoCon Europe over the rest of this week.56* To my mind the killer app for `requests3`/`httpcore` is a high-performance57 proxy server / gateway service in Python. Pitching the growing ASGI ecosystem58 is an important part of that story.59* I think there's enough headroom before PyCon to have something ready to pitch by then.60 I could be involved in sprints remotely if there's areas we still need to fill in,61 anyplace.6263```python64import httpcore6566response = await httpcore.request('GET', 'http://example.com')67assert response.status_code == 20068assert response.body == b'Hello, world'69```7071API...7273```python74response = await httpcore.request(method, url, [headers], [body], [stream])75```7677Explicit PoolManager...7879```python80async with httpcore.PoolManager([ssl], [timeout], [limits]) as pool:81 response = await pool.request(method, url, [headers], [body], [stream])82```