Skip to content

Commit 60e201c

Browse files
Refactor the HTTP Client (#649)
1 parent 3b98873 commit 60e201c

27 files changed

Lines changed: 1859 additions & 1316 deletions

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore = E203, E266, W503, E704, E701, F824, C901
2+
ignore = E203, E266, W503, E704, E701, F824, C901, E501
33
max-line-length = 88
44
max-complexity = 18
55
per-file-ignores =

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.5.0] - 2026-01-26
9+
10+
- Add native HTTP/2 support to the HTTP client with automatic protocol detection
11+
via ALPN (Application-Layer Protocol Negotiation). The client now automatically
12+
uses HTTP/2 when the server supports it, with seamless fallback to HTTP/1.1.
13+
- Add new `HTTP2Connection` class using the `h2` library for HTTP/2 protocol handling.
14+
- Add new `HTTP11Connection` class using the `h11` library for consistent HTTP/1.1 handling
15+
- Both connection types use `asyncio.open_connection` streams for a unified architecture.
16+
- HTTP/2 connections support stream multiplexing, allowing multiple concurrent requests
17+
over a single TCP connection.
18+
- Add `http2` parameter to `ClientSession` (defaults to `True`) to control HTTP/2 usage.
19+
- Protocol detection is performed once per host and cached for efficiency.
20+
- Add `h2>=4.0.0,<5.0.0` as a new dependency.
21+
- **Refactor HTTP/1.1 client implementation** to use the `h11` library instead of
22+
custom request writing methods from `blacksheep.scribe`. This provides a more
23+
robust and standards-compliant HTTP/1.1 state machine, and creates consistency
24+
with the HTTP/2 implementation pattern.
25+
- The new `HTTP11Connection` class replaces the `asyncio.Protocol`-based approach
26+
with a streams-based implementation.
27+
- Remove the legacy `ClientConnection` class has been removed.
28+
- Both HTTP/1.1 and HTTP/2 implementations follow the same architectural pattern.
29+
- Remove the option of passing the event loop to the constructor of client classes.
30+
831
## [2.4.6] - 2026-01-13
932

1033
- Fix CRLF injection vulnerability in the BlackSheep HTTP Client, reported by Jinho Ju (@tr4ce-ju).

blacksheep/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
__author__ = "Roberto Prevato <roberto.prevato@gmail.com>"
7-
__version__ = "2.4.6"
7+
__version__ = "2.5.0"
88

99
from .contents import Content as Content
1010
from .contents import FormContent as FormContent

blacksheep/baseapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import http
22
import inspect
33
import logging
4-
from collections import UserDict
54
import typing
5+
from collections import UserDict
66

77
from blacksheep.server.errors import ServerErrorDetailsHandler
88
from blacksheep.server.routing import Router

0 commit comments

Comments
 (0)