Commit Graph

16 Commits

Author SHA1 Message Date
Jonathan Gamble
34cecb4643 LibWeb+test-web: Allow identical echo registrations in http-test-server
The http-test-server.py change allows repeated fixed /echo route
registration by Text/input/navigation/iframe-referrer-policy.html.
Before this change, the second registration of the same method+path+def
returned 409, causing include.js to throw and fail the test.

Make /echo registration idempotent for identical definitions and return
success, but keep 409 for conflicting redefinitions of an existing
method+path.
2026-02-25 12:33:35 -06:00
Luke Wilde
84db5d8c1c Meta+test-web: Support per-test .headers files
If a test requires custom response headers, we now serve it via the
http-test-server, which will read the headers file and add them to the
response.
2026-02-19 14:58:09 +01:00
Timothy Flynn
8156531477 LibWeb: Decode Set-Cookie response headers before parsing
It's possible for the cookie value from a Set-Cookie header to contain
invalid UTF-8. We must isomorphic decode this header.

This fixes the /cookies/domain/domain-attribute-idn-host.sub.https.html
WPT test. The test added here is a crash test rather than a text test
because we cannot access the received Set-Cookie header from JS on the
file:// test URL.
2026-02-03 07:20:41 -05:00
CountBleck
bc0cceae1f LibWeb: Add a test checking the referrer of worker script fetches
Also, allow the echo server to reflect headers by substituting it into a
provided template body, enabling them to be read programmatically as
part of a script.
2026-01-31 22:45:08 +01:00
Timothy Flynn
453764d3f0 LibHTTP: Do not respond to Range requests with cached full responses
If we have the response for a non-Range request in the memory cache, we
would previously use it in reply to Range requests. Similar to commit
878b00ae61f998a26aad7f50fae66cf969878ad6, we are just punting on Range
requests in the HTTP caches for now.
2026-01-10 09:02:41 -05:00
Timothy Flynn
9f2ac14521 LibHTTP+RequestServer: Do not flush partial responses to the cache index
If the cURL request completes with anything other than CURLE_OK, we must
not keep the cache entry. For example, if the server's connection closes
while transferring data, we receive CURLE_PARTIAL_FILE. We don't want
this cache entry to be treated as valid in a subsequent request.
2026-01-08 11:59:12 +01:00
Timothy Flynn
4053a5f9d4 Tests/LibWeb: Create a copy of the echoed response headers
Otherwise, updates to the local `response_headers` will update the echo
store, which we do not want in upcoming tests.
2026-01-08 11:59:12 +01:00
Timothy Flynn
a4c8e39b99 test-web: Add basic support for If-Mod-Since requests in our test server
This just lets the test decide on a per-request basis if it wants the
test server to respond with a 304.
2025-11-20 09:33:49 +01:00
Julian Dominguez-Schatz
36bfee7f1b Tests: Add 'reflect' option to http-test-server.py
Add an option to http-test-server.py to return received headers as the
response body. This is useful for checking that outgoing headers are
correct, for example in cookie tests.
2025-09-24 10:12:56 +01:00
Timothy Flynn
18718e0876 Meta: Sort all python imports 2025-06-09 11:25:14 -04:00
rmg-x
0cd4c26ae8 Tests/LibWeb: Fix type for delay_ms property in HTTP echo server
This was mistakenly changed from int -> str in a previous commit:
08b8c88ac3
2024-12-07 15:49:15 +00:00
rmg-x
de595b713d Tests/LibWeb: Allow setting custom reason phrase in HTTP echo server 2024-12-06 06:09:44 +00:00
rmg-x
08b8c88ac3 Tests/LibWeb: Use Optional instead of | None syntax in echo script
The `str | None` syntax is only supported in Python 3.10+ and we can
support more Python versions without compromising readability by
importing the `Optional` type.
2024-12-06 06:09:44 +00:00
rmg-x
e4bc6178b9 Tests/LibWeb: Remove duplicate "headers" property in HTTP echo request 2024-12-06 06:09:44 +00:00
rmg-x
4dd21d0b80 Tests/LibWeb: Refactor HTTP echo server script
This commit makes the following changes:
- Adds a model "Echo" for the request body
- Changes the main endpoint from /create to /echo (more REST-y)
- Sends "400: Bad Request" for invalid params or a reserved path
- Sends "409: Conflict" when trying to use an already registered path
- Prints the server port to stdout
- Removes unnecessary subcommands/options (start, stop, --background)
2024-12-05 17:02:57 -07:00
Cory Virok
97d47a38c9 Meta: Add an HTTP echo server to help with testing Browser JS
This allows us to simulate HTTP responses from Browser JS tests.
Instead of using hacks like data URLs to "load" external data,
we can now generate an actual HTTP response that contains
arbitrary headers, body, and has a defined response delay.
2024-11-09 13:08:31 -07:00