httplib2

A comprehensive Python HTTP client with built-in caching, compression, and authentication

Library
PyPI
v0.32.0
511stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity36
Maintenance8
Community84
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
61/100Good
Architecture62
Code Quality68
Innovation55
Learning Curve60

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 Http client 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, and Last-Modified headers
  • 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 requests or httpx
  • 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search