The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): honour If-None-Match: *; cover same-size image rewrites
Teknium9cbaca18cc91
diff --git a/hermes_cli/web_routers/files.py b/hermes_cli/web_routers/files.pyindex d2f92c5b498..f93068e915b 100644--- a/hermes_cli/web_routers/files.py+++ b/hermes_cli/web_routers/files.py@@ -1220,7 +1220,7 @@ async def fs_read_data_url(# HTTP cache and revalidates each time, so an unchanged file costs a 304 instead of its bytes# over a slow link, and a rewritten one is fetched fresh.validators = {"Cache-Control": "private, no-cache", "ETag": _fs_etag(target, st)}- if validators["ETag"] in _if_none_match(request):+ if {validators["ETag"], "*"} & _if_none_match(request):return Response(status_code=304, headers=validators)def _render() -> JSONResponse:diff --git a/tests/hermes_cli/test_web_server_fs_data_url_revalidation.py b/tests/hermes_cli/test_web_server_fs_data_url_revalidation.pyindex 337368f1663..b024fd25c3b 100644--- a/tests/hermes_cli/test_web_server_fs_data_url_revalidation.py+++ b/tests/hermes_cli/test_web_server_fs_data_url_revalidation.py@@ -48,10 +48,13 @@ def test_an_unchanged_image_revalidates_to_304_and_a_rewritten_one_is_read_againunchanged = client.get(route, params=query, headers={"If-None-Match": etag})assert (unchanged.status_code, unchanged.content) == (304, b"")- image.write_bytes(b"second!")+ assert client.get(route, params=query, headers={"If-None-Match": "*"}).status_code == 304++ # Same length, later mtime: an edit in place that keeps the size is still a new image.+ image.write_bytes(b"FIRST")stat = image.stat()os.utime(image, ns=(stat.st_atime_ns, stat.st_mtime_ns + 1_000_000_000))rewritten = client.get(route, params=query, headers={"If-None-Match": etag})assert rewritten.status_code == 200- assert rewritten.json() == {"dataUrl": _data_url(b"second!")}+ assert rewritten.json() == {"dataUrl": _data_url(b"FIRST")}assert rewritten.headers["etag"] != etag