mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Assign the Content-Type fetch response header as appropriate
The condition here was inverted.
This commit is contained in:
parent
b04ef436fa
commit
34b446ab34
Notes:
sideshowbarker
2024-07-16 20:31:50 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/34b446ab34 Pull-request: https://github.com/SerenityOS/serenity/pull/24138
@ -0,0 +1,2 @@
|
||||
text/html
|
||||
text/plain
|
18
Tests/LibWeb/Text/input/fetch-response-content-type.html
Normal file
18
Tests/LibWeb/Text/input/fetch-response-content-type.html
Normal file
@ -0,0 +1,18 @@
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const data = ["<h1>Well hello friends!</h1>"];
|
||||
const blob = new Blob(data, { type: "text/html" });
|
||||
|
||||
const response1 = new Response(blob);
|
||||
|
||||
const response2 = new Response(blob, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
println(response1.headers.get("Content-Type"));
|
||||
println(response2.headers.get("Content-Type"));
|
||||
});
|
||||
</script>
|
@ -113,7 +113,7 @@ WebIDL::ExceptionOr<void> Response::initialize_response(ResponseInit const& init
|
||||
m_response->set_body(body->body);
|
||||
|
||||
// 3. If body’s type is non-null and response’s header list does not contain `Content-Type`, then append (`Content-Type`, body’s type) to response’s header list.
|
||||
if (body->type.has_value() && m_response->header_list()->contains("Content-Type"sv.bytes())) {
|
||||
if (body->type.has_value() && !m_response->header_list()->contains("Content-Type"sv.bytes())) {
|
||||
auto header = Infrastructure::Header {
|
||||
.name = MUST(ByteBuffer::copy("Content-Type"sv.bytes())),
|
||||
.value = MUST(ByteBuffer::copy(body->type->span())),
|
||||
|
Loading…
Reference in New Issue
Block a user