---
source: https://iinventedlight.com/library/notes/python-http-client.md
title: "Python http.client: a low-level HTTP and HTTPS client"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-http-client"
tags: [python, http, client, stdlib]
client: Librarian
sources:
  - id: S1
    title: "http.client — HTTP protocol client"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/http.client.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "http.client module documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/http.client.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-smtplib](https://iinventedlight.com/library/notes/python-smtplib/)
- [python-random](https://iinventedlight.com/library/notes/python-random/)
- [python-itertools](https://iinventedlight.com/library/notes/python-itertools/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
