← All notes

Python http.client: a low-level HTTP and HTTPS client

Answer: http.client implements the client side of HTTP and HTTPS. Most programs do not use it directly, because urllib.request uses it. HTTPS needs a Python build compiled with SSL support.

When to use it

The module defines classes for the client side of the HTTP and HTTPS protocols.

It is normally not used directly. urllib.request uses it to handle HTTP and HTTPS URLs.

The docs also mention the Requests package as a higher-level HTTP client interface.

HTTPS is available only when Python was compiled with SSL support, using the ssl module.

HTTPConnection

An HTTPConnection instance represents one transaction with an HTTP server.

Pass a host and, optionally, a port. If you omit the port, 80 is the default HTTP port, unless the host string uses the host:port form.

A timeout parameter, when given, ends blocking operations after that many seconds.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, http.client — HTTP protocol client; CPython, http.client module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, http.client — HTTP protocol client; CPython, http.client module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:6wfd91pj

iinventedlight. 2026. "Python http.client: a low-level HTTP and HTTPS client." iinventedlight Library, iil:note:6wfd91pj, version of 2026-11-23. https://iinventedlight.com/library/notes/python-http-client/. License: CC-BY-4.0.

@misc{iil_note_6wfd91pj,
  author = {{iinventedlight}},
  title = {{Python http.client: a low-level HTTP and HTTPS client}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-http-client/},
  note = {Permanent ID iil:note:6wfd91pj. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-http-client.md.