# 超文本咖啡壶控制协议

**超文本咖啡壶控制协议（Hyper Text Coffee Pot Control Protocol，HTCPCP）** 是一种戏谑性的通信协议，用于控制、监控和诊断咖啡壶，由 IETF 于 1998 年 4 月 1 日作为[愚人节](https://www.edgepedia.org/zh/april-fools-day)文档发布，规范见 RFC 2324。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> 其作者拉里·马辛特（Larry Masinter）当时任职于施乐帕克研究中心（Xerox PARC），他称这份文档是“一个带有严肃目的的四月一日玩笑”，讽刺了当时人们以不当方式扩展 HTTP 的种种做法。<sup>[2](https://larrymasinter.net/)</sup> 该协议构建在 HTTP 之上，最著名之处在于引入了状态码 418“我是茶壶”，后来该状态码被正式保留在 IANA HTTP 状态码注册表中，因为它作为玩笑被部署得太广，已无法重新分配。<sup>[3](https://www.rfc-editor.org/rfc/rfc9110.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 文档 | RFC 2324，《超文本咖啡壶控制协议（HTCPCP/1.0）》，L. Masinter，1998 年 4 月 1 日，信息类，独立流<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> |
| 基础 | 构建于 HTTP 之上，新增方法（BREW、WHEN、PROPFIND）、新头字段及返回码 406 和 418<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> |
| URI 方案 | 服务器以“coffee:”方案寻址，该词可按 29 种语言中“咖啡”一词的拼写来书写<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> |
| 标志性错误 | 418“我是茶壶”：任何试图用茶壶冲泡咖啡的请求；返回的实体主体可以又矮又胖<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> |
| 茶扩展 | RFC 7168（HTCPCP-TEA），I. Nazar，2014 年 4 月 1 日，为泡茶器具更新 RFC 2324<sup>[4](https://www.rfc-editor.org/rfc/rfc7168.html)</sup> |
| 注册表状态 | RFC 9110（2022）在 IANA HTTP 状态码注册表中将 418 保留为“（未使用）”<sup>[3](https://www.rfc-editor.org/rfc/rfc9110.html)</sup> |
| 配套文档 | RFC 2325 定义了咖啡壶 MIB，用于管理滴滤式加热饮料硬件<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> |

## 目的与理据

RFC 2324 归类为信息类，并明确声明它“不规定任何形式的互联网标准”。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup> 其陈述的理据是：联网咖啡壶需要控制协议，而消费者希望远程控制电器，以便醒来时能喝到刚煮好的咖啡。文档引用了联网电器的真实先例：早期将自动售货设备接入互联网进行状态监控的实验，以及 1990 年首次亮相的、通过 SNMP 控制的“互联网烤面包机”——它是最早接入互联网的远程操作机器之一。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

马辛特本人的叙述明确点出了讽刺对象：该文档指出了 HTTP 被不当扩展的许多方式。<sup>[2](https://larrymasinter.net/)</sup> IETF HTTP 工作组主席马克·诺丁汉（Mark Nottingham）后来写道，HTCPCP 是“拉里开的一个四月一日玩笑，用以说明人们如何以各种方式滥用 HTTP”，并指出其中的讽刺之处：人们竟在自己的 HTTP 栈中实现了 HTCPCP 的部分内容。<sup>[5](https://github.com/nodejs/node/issues/14644)</sup>

## 协议设计

HTCPCP 构建在 HTTP 之上，新增了若干方法、头字段和返回码。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

**方法。** 控制咖啡壶的命令通过 BREW 或 POST 方法发送，消息体内容类型为“application/coffee-pot-command”；咖啡壶服务器必须等价地接受二者，不过用 POST 触发动作的做法已不推荐。文档解释了新增 BREW 的理由，并指出 POST 可能是咖啡的商标。GET 方法予以保留，并附注说明：在 HTCPCP 中，与咖啡壶相关的资源是物理资源而非信息资源，“大多数咖啡 URI 的‘数据’不含咖啡因”。关于冲泡资源的元数据通过借用自 WebDAV 的 PROPFIND 方法发现。WHEN 方法处理牛奶：倒咖啡并提供牛奶时，接受者在牛奶量足够的那一刻说“够了”。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

**头字段与媒体类型。** 协议定义了 Accept-Additions 头字段，用于指定可接受的咖啡添加物，并扩展了“Safe”响应头，增加了一个条件安全值“if-user-awake”。POST 或 BREW 请求的实体主体必须为内容类型“message/coffeepot”，其内容仅为取值为“start”或“stop”的 coffee-message-body。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

**返回码。** HTCPCP 复用了 406 Not Acceptable，当咖啡壶操作员无法满足 Accept-Additions 请求时可以返回该码；并定义了 418“我是茶壶”：任何试图用茶壶冲泡咖啡的请求都应导致此错误码，返回的实体主体可以又矮又胖。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

**寻址。** 所有 HTCPCP 服务器都应使用“coffee:”URI 方案指称。由于咖啡是国际性的，规范允许方案名采用 29 种语言中“咖啡”一词的 URL 编码 UTF-8 拼写，包括“koffie”（[南非荷兰语](https://www.edgepedia.org/zh/afrikaans)、荷兰语）、阿拉伯语、孟加拉语、俄语和泰语；所有替代形式均等价。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

**操作。** 文档建议咖啡壶使用[网络时间协议](https://www.edgepedia.org/zh/network-time-protocol)同步时钟，并论证：通过将 HTCPCP 构建于 HTTP 之上并使用 80 端口，协议继承了 HTTP 穿越防火墙的优点。其安全考虑章节警告要防范“拒绝咖啡服务”攻击，指出过滤装置使用不当可能混入特洛伊咖啡渣，并观察到将咖啡渣倒入互联网管道可能导致管道堵塞，需要请互联网水管工。<sup>[1](https://www.rfc-editor.org/rfc/rfc2324.html)</sup>

## 茶扩展

RFC 7168《面向茶饮流出器具的超文本咖啡壶控制协议（HTCPCP-TEA）》由伊姆兰·纳扎尔（Imran Nazar）于 2014 年 4 月 1 日发布，更新了 RFC 2324。<sup>[4](https://www.rfc-editor.org/rfc/rfc7168.html)</sup> 它指出，基础规范对联网茶壶的唯一规定是茶壶不得响应冲泡咖啡的请求，这使得无法为茶壶的预期用途与其通信。该扩展保留 BREW 和 POST 作为控制方法，为各品种茶新增了特定 URI，使用 Alternates 头在咖啡之外通告茶品种，定义了“message/teapot”媒体类型，并在继承的 418 之外新增了 300 Multiple Options 和 403 Forbidden 等响应码。<sup>[4](https://www.rfc-editor.org/rfc/rfc7168.html)</sup>

## 遗产：状态码 418

该协议最持久的产物是 418 状态码。包括 Node.js、Go、Python 的 Requests 库和 [ASP.NET](https://www.edgepedia.org/zh/asp-net) 的 HttpAbstractions 在内的 HTTP 库都实现了它，2018 年一次 npm 代理故障曾短暂向用户返回“npm ERR! 418 I'm a teapot”。<sup>[6](https://www.theregister.com/2018/05/29/npm_teapot/)</sup>

2017 年 8 月，时任 IETF HTTP 和 QUIC 工作组主席的马克·诺丁汉向 Node.js 和 Go 提交问题，要求移除对 418 的支持，理由是该码并非 HTTP 状态码，且占用了未来真实语义可能需要的注册表空间。<sup>[5](https://github.com/nodejs/node/issues/14644)</sup><sup> • </sup><sup>[7](https://github.com/golang/go/issues/21326)</sup> 移除努力遭遇广泛抵制，被 Node.js 技术指导委员会成员詹姆斯·M·斯内尔（James M. Snell）叫停；诺丁汉随后改变方向，寻求将 418 正式保留。<sup>[6](https://www.theregister.com/2018/05/29/npm_teapot/)</sup>

结果被编入 RFC 9110（《HTTP 语义》，2022 年 6 月），其中记载：RFC 2324 讽刺了应用特定 418 状态码的定义；该码“作为玩笑被部署得足够广泛，以致无法用于未来任何用途”；因此 418 被保留在 IANA HTTP 状态码注册表中，列为“（未使用）”，仅在未来情况需要时可重新分配。<sup>[3](https://www.rfc-editor.org/rfc/rfc9110.html)</sup> IANA 注册表目前将 418 列为“（未使用）”，引用 RFC 9110 第 15.5.19 节。<sup>[8](https://www.iana.org/assignments/http-status-codes)</sup> MDN 将该码记录为表示服务器拒绝冲泡咖啡，因为它永久地是一把茶壶，并指出一些网站将其用于不愿处理的请求，如自动查询。<sup>[9](https://github.com/mdn/content/blob/main/files/en-us/web/http/reference/status/418/index.md)</sup>

## 实现

尽管具有讽刺性质，HTCPCP 仍吸引了可用的实现。一个实现 RFC 2324 的 C 客户端和服务器是作为 2011 年大学网络课程项目编写的。<sup>[10](https://github.com/madmaze/HTCPCP)</sup> 一个树莓派项目将实体咖啡壶和可编程电源排插与基于 Flask 的 HTCPCP 服务器配对，接受 BREW 请求。<sup>[11](https://github.com/hypertextcoffeepot/hypertextcoffeepot)</sup> 一个较新的 Python 实现指出了一个实际障碍：uvicorn 等主流 HTTP 服务器在套接字层面验证方法名，会拒绝 BREW、WHEN 和 PROPFIND 这些未在 IANA 注册的方法，因此合规服务器需要自己的 HTTP 解析器，接受任何有效的 RFC 7230 令牌作为方法名。<sup>[12](https://github.com/pcescato/htcpcp)</sup> 一个简单的 Go 茶壶服务器对普通请求返回 418，对 BREW 返回 200“正在泡茶。”。<sup>[13](https://github.com/mxstbr/teapot)</sup>

RFC 2324 也属于一个传统：[RFC 编辑](https://www.edgepedia.org/zh/rfc-editor)自 1978 年起每年 4 月 1 日发布幽默 RFC，一份回顾性指南将 RFC 2324 与 RFC 1149（禽类载体）和 RFC 3514（邪恶位）并列为最具影响力的作品，并指出 418 在生产框架中运行。<sup>[14](https://www.freecodecamp.org/news/the-internet-s-longest-running-joke-a-field-guide-to-the-april-fools-rfcs)</sup>

## References

1. [RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0), L. Masinter, 1 April 1998, RFC Editor](https://www.rfc-editor.org/rfc/rfc2324.html)
2. [Larry Masinter's talks, publications, activities](https://larrymasinter.net/)
3. [RFC 9110: HTTP Semantics, June 2022, RFC Editor](https://www.rfc-editor.org/rfc/rfc9110.html)
4. [RFC 7168: The Hyper Text Coffee Pot Control Protocol for Tea Efflux Appliances (HTCPCP-TEA), I. Nazar, 1 April 2014, RFC Editor](https://www.rfc-editor.org/rfc/rfc7168.html)
5. [418 I'm A Teapot, nodejs/node issue #14644, August 2017](https://github.com/nodejs/node/issues/14644)
6. [Storm in a teapot: Anger brews over npm's jokey proxy error messages, The Register, 30 May 2018](https://www.theregister.com/2018/05/29/npm_teapot/)
7. [net/http: remove support for status code 418 I'm a Teapot, golang/go issue #21326, August 2017](https://github.com/golang/go/issues/21326)
8. [Hypertext Transfer Protocol (HTTP) Status Code Registry, IANA](https://www.iana.org/assignments/http-status-codes)
9. [418 I'm a teapot, MDN Web Docs source](https://github.com/mdn/content/blob/main/files/en-us/web/http/reference/status/418/index.md)
10. [madmaze/HTCPCP: Basic C implementation of RFC 2324](https://github.com/madmaze/HTCPCP)
11. [HyperTextCoffeePot: HTCPCP server on a Raspberry Pi](https://github.com/hypertextcoffeepot/hypertextcoffeepot)
12. [pcescato/htcpcp: Hyper Text Coffee Pot Control Protocol Implementation](https://github.com/pcescato/htcpcp)
13. [mxstbr/teapot: A simple teapot server in Go](https://github.com/mxstbr/teapot)
14. [The Internet's Longest-Running Joke: A Field Guide to the April Fools RFCs, freeCodeCamp](https://www.freecodecamp.org/news/the-internet-s-longest-running-joke-a-field-guide-to-the-april-fools-rfcs)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › HTTP and web communication protocols

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hyper-text-coffee-pot-control-protocol

English original: https://www.edgepedia.org/hyper-text-coffee-pot-control-protocol
