HTCPCP (RFC 2324 + RFC 7168) extension for the BlackBull ASGI framework.
Project description
blackbull-htcpcp
A BlackBull extension implementing HTCPCP — the Hyper Text Coffee Pot Control Protocol from RFC 2324 (1998 April Fool's) and its tea-pot extension RFC 7168 (2014 April Fool's).
The joke is well-known. The reason to actually ship it is that HTCPCP is a small, frozen RFC that uses every awkward corner of HTTP at once — a custom method, a custom status code, a custom content type, an application-defined request header with its own grammar, and error semantics that aren't really about HTTP itself. Implementing it end-to-end in roughly 350 lines on top of an unmodified web framework makes a fine worked example for how far HTTP can be pushed as an application-protocol carrier.
Here is what the package actually puts on the wire:
POST /pot HTTP/1.1 ← BREW, while http.HTTPMethod still rejects non-IANA verbs
Host: localhost:8000
Accept-Additions: cream; sugar
HTTP/1.1 200 OK
Content-Type: message/coffeepot
{"pot-type": "coffee", "state": "ready", "additions": ["cream", "sugar"]}
Ask a teapot to brew coffee, and it answers honestly:
POST /pot HTTP/1.1
Host: localhost:8000
HTTP/1.1 418 I'm a teapot
Content-Type: message/coffeepot
{"error": "I'm a teapot", "pot-type": "teapot"}
All of it sits on BlackBull's documented init_app(app) extension surface — no framework fork, no monkey-patches. See src/blackbull_htcpcp/extension.py.
Install
pip install blackbull-htcpcp
Use
from blackbull import BlackBull
from blackbull_htcpcp import HtcpcpExtension
app = BlackBull()
HtcpcpExtension(app=app, pot_type='coffee') # or pot_type='teapot'
# Deferred form, if you configure the app elsewhere:
ext = HtcpcpExtension(pot_type='teapot')
ext.init_app(app)
After init_app(app) the live extension sits at app.extensions['htcpcp']. Four routes (BREW / PROPFIND / WHEN / GET) are registered on /pot, a readiness route at /pot/when, plus an app.on_error(418) handler so any 418 the rest of the app emits gets the same message/coffeepot body.
What it implements
- BREW — start brewing. Maps to POST on
/potwhile the stdlibhttp.HTTPMethodenum keeps rejecting non-IANA verbs. - PROPFIND — inspect the pot's metadata. Exposed via GET in the same window; native PROPFIND verb gated on the same framework change.
- WHEN — readiness check (GET
/pot/when). - 418 I'm a teapot — RFC 2324 §2.2.2. A teapot brewing anything that isn't tea returns 418. Coffee pots return 200 for any brew request.
message/coffeepot— content type on every/potresponse, success or error.- Accept-Additions —
cream; sugar; vanillaetc. Parsed, lower-cased, validated.
Configuration
| Parameter | Default | Notes |
|---|---|---|
pot_type |
'coffee' |
'coffee' or 'teapot'. Decides which Accept-Additions are valid and when 418 fires. |
capacity_ml |
1500 |
Reported via PROPFIND. Doesn't enforce anything — the pot is metaphorical. |
Security
HTCPCP is a joke; the parser isn't. Accept-Additions is rejected when an addition token contains:
- CRLF or bare LF (response splitting),
- a NULL byte,
- non-printable control characters (other than horizontal tab — valid OWS per RFC 9110 §5.6.3),
- more than 256 characters,
or when the request carries more than 64 addition tokens. BREW request bodies are capped at 1 MiB. See tests/test_htcpcp.py for the full S001–S015 matrix.
How it fits
blackbull-htcpcp is the second external extension built on BlackBull's init_app(app) convention, after blackbull-session. It exists partly to prove that the extension surface can carry a non-trivial application protocol — custom methods, custom content types, custom error semantics — without modifications to the framework itself. The cultural reference is IPoAC (RFC 1149, implemented by Bergen Linux User Group in 2001): the joke RFCs are funny because they could actually be implemented, and implementing them teaches something about the layer underneath.
License
Apache License 2.0 — © TOKUJI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blackbull_htcpcp-0.1.0.tar.gz.
File metadata
- Download URL: blackbull_htcpcp-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f99aee317a2069f78f32fa4bb83c6e9384024c5bd5dfc0063d58aaf388f750a
|
|
| MD5 |
ee12a6da7594be55193255c55ea7c4e4
|
|
| BLAKE2b-256 |
e9ac84486aa44e07348b63a503b887d5c48a16a9484b460548e641530dbeb67d
|
Provenance
The following attestation bundles were made for blackbull_htcpcp-0.1.0.tar.gz:
Publisher:
publish.yml on TOKUJI/blackbull-htcpcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackbull_htcpcp-0.1.0.tar.gz -
Subject digest:
6f99aee317a2069f78f32fa4bb83c6e9384024c5bd5dfc0063d58aaf388f750a - Sigstore transparency entry: 1850326134
- Sigstore integration time:
-
Permalink:
TOKUJI/blackbull-htcpcp@271de25b7e5d20947904ec18c16947b95e1714ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TOKUJI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@271de25b7e5d20947904ec18c16947b95e1714ed -
Trigger Event:
push
-
Statement type:
File details
Details for the file blackbull_htcpcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: blackbull_htcpcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
030d07c98aa501223f252d995b73ad3bb0ea8d337d8f1721292dda05c6204b07
|
|
| MD5 |
343dcfa03066d0b9c5765204e164216b
|
|
| BLAKE2b-256 |
e936e16517af3d84eec236378cfebd99679e3231b8657061fd1b53395818cabb
|
Provenance
The following attestation bundles were made for blackbull_htcpcp-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on TOKUJI/blackbull-htcpcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
blackbull_htcpcp-0.1.0-py3-none-any.whl -
Subject digest:
030d07c98aa501223f252d995b73ad3bb0ea8d337d8f1721292dda05c6204b07 - Sigstore transparency entry: 1850326378
- Sigstore integration time:
-
Permalink:
TOKUJI/blackbull-htcpcp@271de25b7e5d20947904ec18c16947b95e1714ed -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/TOKUJI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@271de25b7e5d20947904ec18c16947b95e1714ed -
Trigger Event:
push
-
Statement type: