Hyper HTTP/2 Client for Python (hyper-up)
hyper-up is a Python HTTP/2 client library, providing an API similar to Python's `http.client` for interacting with HTTP/2 servers. It is a fork of the `hyper` project by Lukasa, which has been explicitly abandoned since 2021. The `hyper-up` package itself has not seen updates since 2017, making it unmaintained and potentially insecure. Users are strongly advised to use modern, actively maintained HTTP clients instead.
Common errors
-
from hyper import HTTPConnection ModuleNotFoundError: No module named 'hyper'
cause Despite the package name being `hyper-up` on PyPI, the core classes are imported from the `hyper` namespace.fixEnsure `pip install hyper-up` was successful. The import statement `from hyper import HTTPConnection` is correct for this library. -
ssl.SSLError: [SSL: TLSV1_UNRECOGNIZED_NAME] tlsv1 unrecognized name (_ssl.c:XXXX)
cause This error often occurs when `hyper-up` (or its underlying OpenSSL/Python SSL context) struggles to negotiate TLS with modern servers, likely due to outdated or insecure cipher suites, protocol versions, or SNI issues given the library's age.fixThis library is not suitable for secure communication with modern HTTPS servers. The fundamental fix is to migrate to a maintained library like `httpx`. Attempting to manually configure SSL contexts with `hyper-up` is highly discouraged and unlikely to be secure.
Warnings
- breaking The upstream `hyper` project, which `hyper-up` is based on, has been explicitly abandoned since 2021, recommending alternatives. `hyper-up` itself has not been updated since 2017.
- breaking Using `hyper-up` poses significant security risks due to unpatched vulnerabilities in its core HTTP/2 implementation and underlying dependencies, especially regarding TLS/SSL.
- gotcha The API of `hyper-up` (via `hyper` import) is designed to be similar to Python's `http.client`, which can be less ergonomic than modern `requests`-style APIs.
Install
-
pip install hyper-up
Imports
- HTTPConnection
from hyper import HTTPConnection
Quickstart
import ssl
from hyper import HTTPConnection
# Note: http2bin.org is an example; actual HTTP/2 server availability may vary.
# This library is unmaintained and may have security vulnerabilities.
try:
# Using HTTPS for HTTP/2. The default port for HTTP/2 over TLS is 443.
conn = HTTPConnection('http2bin.org:443')
conn.request('GET', '/get')
resp = conn.get_response()
print(f"Status: {resp.status}")
print(f"Headers: {resp.headers}")
print(f"Body: {resp.read().decode('utf-8')}")
except ssl.SSLError as e:
print(f"SSL Error: {e}. This often indicates issues with TLS negotiation or outdated cryptography.")
except Exception as e:
print(f"An unexpected error occurred: {e}")