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:
parent
08b8c88ac3
commit
de595b713d
Notes:
github-actions[bot]
2024-12-06 06:10:39 +00:00
Author: https://github.com/rmg-x
Commit: de595b713d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2802
Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 3 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue