From 6dbe36ea076ae4f00a3af509f490c0d1987f8b59 Mon Sep 17 00:00:00 2001 From: ldm0 Date: Sat, 12 Sep 2026 04:13:28 +0800 Subject: [PATCH] fix(wpt): serve the XHR request-header echo fixture --- moli-benchmark/moli_benchmark/wpt_cross/case_set.py | 2 +- moli-benchmark/moli_benchmark/wpt_cross/server.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/moli-benchmark/moli_benchmark/wpt_cross/case_set.py b/moli-benchmark/moli_benchmark/wpt_cross/case_set.py index 2bf44cd76..2fb7485c0 100644 --- a/moli-benchmark/moli_benchmark/wpt_cross/case_set.py +++ b/moli-benchmark/moli_benchmark/wpt_cross/case_set.py @@ -819,7 +819,7 @@ def _empty_location_handler_reference_patterns(directory: str) -> tuple[re.Patte def _xhr_handler_reference_patterns(directory: str) -> tuple[re.Pattern[str], ...]: references = [] for name in ( - "requri.py", "redirect.py", "inspect-headers.py", "content.py", + "requri.py", "redirect.py", "inspect-headers.py", "echo-headers.py", "content.py", "echo-content-type.py", "win-1252-xml.py", "win-1252-html.py", "invalid-utf8-html.py", "shift-jis-html.py", "img-utf8-html.py", "empty-div-utf8-html.py", "status.py", "last-modified.py", diff --git a/moli-benchmark/moli_benchmark/wpt_cross/server.py b/moli-benchmark/moli_benchmark/wpt_cross/server.py index 393ffdbf1..f93438a1a 100644 --- a/moli-benchmark/moli_benchmark/wpt_cross/server.py +++ b/moli-benchmark/moli_benchmark/wpt_cross/server.py @@ -116,6 +116,7 @@ XHR_RESOURCE_PATHS = { "/xhr/resources/requri.py", "/xhr/resources/redirect.py", "/xhr/resources/inspect-headers.py", + "/xhr/resources/echo-headers.py", "/xhr/resources/content.py", "/xhr/resources/echo-content-type.py", "/xhr/resources/status.py", @@ -2943,6 +2944,11 @@ def _make_handler( headers, body = _xhr_inspect_headers_fixture_response( parsed.query, list(self.headers.raw_items()) ) + elif path == "/xhr/resources/echo-headers.py": + status, reason = 200, None + headers = [("Content-Type", "text/plain")] + # wptserve exposes the same HTTPMessage as raw_headers. + body = str(self.headers).encode("utf-8") elif path == "/xhr/resources/content.py": params = parse_qs(parsed.query, keep_blank_values=True, encoding="latin-1") if "content" in params: @@ -2997,7 +3003,9 @@ def _make_handler( return True # Close connections with unread uploads so early responses and # redirects do not wait for the request body to finish. - if path == "/xhr/resources/echo-content-type.py" or not upload_consumed and ( + if path in { + "/xhr/resources/echo-content-type.py", "/xhr/resources/echo-headers.py" + } or not upload_consumed and ( self.headers.get("Transfer-Encoding") is not None or self.headers.get("Content-Length", "0").strip() not in {"", "0"} ):