Skip to content

Commit 79bb848

Browse files
ehsun-shclaude
andcommitted
Speak HTTP/1.1
http.server answers HTTP/1.0 unless told otherwise. That costs a fresh connection per request, and leaves `Cache-Control: no-store` on weaker footing than it should be — it is an HTTP/1.1 header, and this page is edited between reloads constantly, which is exactly when a stale copy is most confusing to look at. Every response already carries an accurate Content-Length, which is what 1.1 needs to hold a connection open, so this is an unset switch rather than a change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 488da1d commit 79bb848

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/maiman/server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ class StudioHandler(BaseHTTPRequestHandler):
275275
server_version = "maiman"
276276
sys_version = ""
277277

278+
#: http.server speaks HTTP/1.0 unless told otherwise, which costs a fresh
279+
#: connection per request and leaves cache directives on weaker footing than
280+
#: they should be — `Cache-Control: no-store` is an HTTP/1.1 header, and the
281+
#: page is edited between reloads constantly. Every response here already
282+
#: carries an accurate Content-Length, which is what 1.1 requires to keep a
283+
#: connection open, so this is an unset switch rather than a change.
284+
protocol_version = "HTTP/1.1"
285+
278286
# -- plumbing ---------------------------------------------------------
279287

280288
def _send(self, status: HTTPStatus, payload: dict[str, Any]) -> None:

0 commit comments

Comments
 (0)