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
- id: C1 claim: The module implements the client side of the HTTP and HTTPS protocols. source: S1 evidence: "implement the client side of the HTTP and HTTPS protocols"
- id: C2 claim: It is normally not used directly; urllib.request uses it. source: S1 evidence: "normally not used directly"
- id: C3 claim: HTTPS support is available only if Python was compiled with SSL support. source: S1 evidence: "HTTPS support is only available if Python was compiled with SSL support"
- id: C4 claim: An HTTPConnection represents one transaction with an HTTP server. source: S2 evidence: "represents one transaction with an HTTP server"
Sources
- [S1] http.client — HTTP protocol client. Python Software Foundation. https://docs.python.org/3/library/http.client.html . License: PSF License Version 2. Accessed 2026-11-23.
- [S2] http.client module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/http.client.rst . License: PSF License Version 2. Accessed 2026-11-23.
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
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.},
}
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.
- python-http-client.schema.json (schema; CC-BY-4.0)
- python-http-client.table.json (table; CC-BY-4.0)
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.