LibWeb: Avoid re-encoding response headers

isomorphic encoding a value that has already been encoded will
result in garbage data. `response_headers` is already encoded in
ISO-8859-1/latin1, we cannot use `from_string_pair`, as it triggers
ISO-8859-1/latin1 encoding.

Follow-up of https://github.com/LadybirdBrowser/ladybird/pull/1893
This commit is contained in:
Feng Yu 2024-12-12 10:26:41 -08:00 committed by Jelle Raaijmakers
commit e0c0668f3d
Notes: github-actions[bot] 2024-12-17 12:45:04 +00:00
6 changed files with 22 additions and 7 deletions

View file

@ -58,6 +58,14 @@ Header Header::from_string_pair(StringView name, StringView value)
};
}
Header Header::from_latin1_pair(StringView name, StringView value)
{
return Header {
.name = MUST(ByteBuffer::copy(name.bytes())),
.value = MUST(ByteBuffer::copy(value.bytes())),
};
}
GC::Ref<HeaderList> HeaderList::create(JS::VM& vm)
{
return vm.heap().allocate<HeaderList>();