mirror of
https://github.com/lexmount/moli.git
synced 2026-09-27 08:01:34 +00:00
fix(wpt): serve the XHR request-header echo fixture
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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"}
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user