diff --git a/Tests/LibWeb/Text/expected/fetch-response-content-type.txt b/Tests/LibWeb/Text/expected/fetch-response-content-type.txt new file mode 100644 index 00000000000..26b1f59734c --- /dev/null +++ b/Tests/LibWeb/Text/expected/fetch-response-content-type.txt @@ -0,0 +1,2 @@ +text/html +text/plain diff --git a/Tests/LibWeb/Text/input/fetch-response-content-type.html b/Tests/LibWeb/Text/input/fetch-response-content-type.html new file mode 100644 index 00000000000..a809b5555a8 --- /dev/null +++ b/Tests/LibWeb/Text/input/fetch-response-content-type.html @@ -0,0 +1,18 @@ + + diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 839ee6f3133..4acc5c24b87 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -113,7 +113,7 @@ WebIDL::ExceptionOr 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())),