Files
ladybird/Tests/LibWeb/Text/input/Fetch/header-whitespace-normalization.html
Shannon Booth 74109d2f6b RequestServer: Only trim HTTP whitespace from response headers
The Fetch spec defines HTTP whitespace as tab, LF, CR, and space.
Previously, trim_whitespace was also stripping vertical tab (U+000B)
and form feed (U+000C), which are not HTTP whitespace characters.
Switch to HTTP::normalize_header_value which matches the fetch
definition.

Fixes 4 subtests for WPT test:

https://wpt.live/cors/origin.htm
2026-02-26 20:01:13 +01:00

27 lines
913 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
try {
const httpServer = httpTestServer();
const url = await httpServer.createEcho("GET", `/header-whitespace-normalization`, {
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Expose-Headers": "X-Test-Header",
"X-Test-Header": '\u000B' + "hello" + '\u000C',
},
});
const resp = await fetch(url);
const value = resp.headers.get("X-Test-Header");
if (value !== '\u000Bhello\u000C') {
println("FAIL - got: " + JSON.stringify(value));
return;
}
println("PASS");
} catch (err) {
println("FAIL - " + err);
}
});
</script>