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:
parent
575e3bf37d
commit
0ca1b4b123
1 changed files with 5 additions and 2 deletions
|
@ -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 this’s headers’s header list does not contain `Content-Type`, then append (`Content-Type`, type) to this’s 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue