httplib2
A comprehensive Python HTTP client with built-in caching, compression, and authentication
Repository Health
Technical Analysis
httplib2 is a Python HTTP client library that predates and still fills gaps left by more commonly used clients like requests and the standard library’s http.client. It supports HTTP and HTTPS, persistent connections via HTTP/1.1 Keep-Alive, and RFC-compliant response caching using ETag and Last-Modified validators through a pluggable cache store.
Beyond the transport layer, it handles Digest, Basic, and WSSE authentication out of the box, automatically follows 3xx redirects on GET requests, transparently decodes gzip and deflate response bodies, and re-attaches cached ETags on PUT requests to guard against lost updates. It has long been a dependency of Google’s API client libraries (google-api-python-client), which keeps it in wide production use despite its age.
What You Get
- An
Httpclient class supporting HTTP and HTTPS with HTTP/1.1 Keep-Alive connection reuse - Transparent response caching using a pluggable cache backend, honoring
Cache-Control,ETag, andLast-Modifiedheaders - Built-in Digest, Basic, and WSSE authentication handling for both HTTP and HTTPS
- Automatic gzip and deflate response decompression
- Automatic following of 3XX redirects on GET requests
- Lost-update protection by re-attaching cached ETags to PUT requests targeting already-cached resources
Common Use Cases
- As the underlying transport for Google API client libraries (
google-api-python-client) that still depend on it - Scripts and services needing conditional-GET caching semantics (ETag/Last-Modified) without hand-rolling cache-validation logic
- Legacy Python codebases already built around httplib2’s API that haven’t migrated to
requestsorhttpx - Environments needing built-in Digest or WSSE authentication without adding a separate auth library
Under The Hood
Architecture - The library is a single httplib2/__init__.py module (~1,800 lines) defining the Http class, which wraps Python’s socket/ssl handling directly rather than delegating to http.client, giving it control over connection reuse, redirect handling, and cache-validation logic in one place; supporting concerns are split into sibling modules — auth.py (Digest/Basic/WSSE handlers), decode.py (gzip/deflate response decoding), certs.py (CA bundle handling), error.py (exception types), and iri2uri.py (IRI-to-URI conversion for internationalized URLs). Tech Stack - Pure Python with no required third-party runtime dependencies, relying on the standard library’s socket/ssl modules directly; the test suite uses pytest with pytest-forked (per the setup.py test command) to isolate socket-level tests. Code Quality - The tests/ directory has 21 files and roughly 145 test functions covering HTTP, HTTPS, proxying, caching, authentication, and URI handling (test_http.py, test_https.py, test_proxy.py, test_cache.py, test_auth.py, test_uri.py), plus fuzz-test scripts (fuzz_request.py, fuzz_url.py) for request/URL parsing; codecov.yml indicates coverage is tracked in CI. API Design - The core workflow is a two-step Http() then .request(uri, method, body, headers) call returning (response, content), which keeps the common case simple, though the tuple-return style and manual cache-directory wiring feel dated next to requests’ session-based API.
Used by 4 apps in this directory
ClickHouse
Databases · Analytics · Data Engineering
Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.
cocoindex
Data Engineering · AI Development
An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.
Helicone
Monitoring · AI Development · Analytics
An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.
Redash
Analytics · Data Engineering
Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.