1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

LibWeb: Don't replace existing Content-Type header in outgoing XHRs

This fixes an issue where Twitter was HTTP 400'ing some of our XHRs.
This commit is contained in:
Andreas Kling 2022-09-18 12:23:02 +02:00
parent 575e3bf37d
commit 0ca1b4b123

View file

@ -493,8 +493,11 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<XMLHttpRequestBodyInit> bod
auto byte_buffer = TRY(ByteBuffer::copy(blob->bytes()));
request.set_body(byte_buffer);
return {}; }, [](auto&) -> ErrorOr<void> { return {}; }));
if (body_with_type->type.has_value())
request.set_header("Content-Type", String { body_with_type->type->span() });
if (body_with_type->type.has_value()) {
// If type is non-null and thiss headerss header list does not contain `Content-Type`, then append (`Content-Type`, type) to thiss headers.
if (!m_request_headers.contains("Content-Type"sv))
request.set_header("Content-Type", String { body_with_type->type->span() });
}
}
for (auto& it : m_request_headers)
request.set_header(it.key, it.value);