1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

Tests/LibWeb: Allow setting custom reason phrase in HTTP echo server

This commit is contained in:
rmg-x 2024-12-05 19:21:06 -06:00 committed by Tim Ledbetter
parent 08b8c88ac3
commit de595b713d
Notes: github-actions[bot] 2024-12-06 06:10:39 +00:00

View file

@ -25,6 +25,7 @@ class Echo:
headers: Optional[Dict[str, str]]
body: Optional[str]
delay_ms: Optional[str]
reason_phrase: Optional[str]
# In-memory store for echo responses
@ -56,6 +57,7 @@ class TestHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
echo.body = data.get("body", None)
echo.delay_ms = data.get("delay_ms", None)
echo.headers = data.get("headers", None)
echo.reason_phrase = data.get("reason_phrase", None)
is_using_reserved_path = echo.path.startswith("/static") or echo.path.startswith("/echo")
@ -126,7 +128,7 @@ class TestHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
time.sleep(echo.delay_ms / 1000)
# Send the status code without any default headers
self.send_response_only(echo.status)
self.send_response_only(echo.status, echo.reason_phrase)
# Set only the headers defined in the echo definition
if echo.headers is not None: