@@ -4,16 +4,17 @@ BlackSheep includes an implementation of HTTP Client for HTTP 1.1.
44
55## Client features
66
7- - HTTP connection pooling
8- - User-friendly handling of SSL contexts (safe by default)
9- - Support for client side middlewares
7+ - HTTP connection pooling.
8+ - User-friendly handling of SSL contexts (safe by default).
9+ - Support for client side middlewares.
1010- Automatic handling of redirects (can be disabled, validates circular
1111 redirects and maximum number of redirects - redirects to URN are simply
12- returned to code using the client)
12+ returned to code using the client).
1313- Automatic handling of cookies (can be disabled, ` Set-Cookie ` and ` Cookie `
14- headers)
14+ headers).
1515
1616** Example:**
17+
1718``` python
1819import asyncio
1920from blacksheep.client import ClientSession
@@ -30,7 +31,6 @@ async def client_example(loop):
3031
3132loop = asyncio.get_event_loop()
3233loop.run_until_complete(client_example(loop))
33-
3434```
3535
3636## HTTP Connection pooling
@@ -59,7 +59,6 @@ design pattern, and this is supported in BlackSheep.
5959
6060``` python
6161async def client_example_middleware (request , next_handler ):
62-
6362 # do something before the request is sent
6463 response = await next_handler(request)
6564
@@ -86,7 +85,6 @@ if it was created for the client.
8685It is recommended to instantiate a single instance of HTTP client and
8786register it as a service of the application, using the ` @app.lifespan ` method:
8887
89- ``` python
9088``` python
9189from blacksheep import Application
9290from blacksheep.client.session import ClientSession
@@ -111,5 +109,5 @@ async def home(http_client: ClientSession):
111109```
112110
113111When following this approach, the HTTP client can be automatically injected
114- into request handlers, and services that need it, and is automatically disposed
112+ into request handlers and services that need it, and is automatically disposed
115113of when the application is stopped.
0 commit comments