You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> r = cli.request("GET", "https://www.example.com/")
60
+
```
61
+
62
+
```{ .python .ahttpx .hidden }
63
+
>>> async with ahttpx.Client() as cli:
64
+
>>> r = await cli.request("GET", "https://www.example.com/")
37
65
```
38
66
39
67
The `Client` class sends requests using a `ConnectionPool`, which is responsible for managing a pool of HTTP connections. This ensures quicker and more efficient use of resources than opening and closing a TCP connection with each request. The connection pool also handles HTTP proxying if required.
40
68
41
69
A single connection pool is able to handle multiple concurrent requests, with locking in place to ensure that the pool does not become over-saturated.
42
70
43
-
```python
44
-
with httpx.ConnectionPool() as pool:
45
-
r = pool.request("GET", "https://www.example.com/")
>>> r = pool.request("GET", "https://www.example.com/")
76
+
```
77
+
78
+
```{ .python .ahttpx .hidden }
79
+
>>> async with ahttpx.ConnectionPool() as pool:
80
+
>>> r = await pool.request("GET", "https://www.example.com/")
46
81
```
47
82
48
83
Individual HTTP connections can be managed directly with the `Connection` class. A single connection can only handle requests sequentially. Locking is provided to ensure that requests are strictly queued sequentially.
49
84
50
-
```python
51
-
with httpx.open_connection("https://www.example.com/") as conn:
>>> with httpx.open_connection("https://www.example.com/") as conn:
89
+
>>> r = conn.request("GET", "/")
90
+
```
91
+
92
+
```{ .python .ahttpx .hidden }
93
+
>>> async with ahttpx.open_connection("https://www.example.com/") as conn:
94
+
>>> r = await conn.request("GET", "/")
53
95
```
54
96
55
97
Protocol handling is dealt with using [the `h11` package](https://h11.readthedocs.io/en/latest/), a rigorously designed HTTP/1.1 implementation which follows [the Sans-IO design pattern](https://sans-io.readthedocs.io/).
@@ -60,33 +102,61 @@ The `NetworkBackend` is responsible for managing the TCP stream, providing a raw
0 commit comments