mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 12:37:40 +00:00
LibWeb: XHR::extra_body() rewrite to use Variant::visit()
This commit is contained in:
parent
48b59aaeb1
commit
bc4ccadcac
1 changed files with 11 additions and 11 deletions
|
@ -313,17 +313,17 @@ Optional<MimeSniff::MimeType> XMLHttpRequest::extract_mime_type(Fetch::HeaderLis
|
||||||
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
|
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
|
||||||
static XMLHttpRequest::BodyWithType extract_body(XMLHttpRequestBodyInit const& body)
|
static XMLHttpRequest::BodyWithType extract_body(XMLHttpRequestBodyInit const& body)
|
||||||
{
|
{
|
||||||
if (body.has<NonnullRefPtr<URL::URLSearchParams>>()) {
|
XMLHttpRequest::BodyWithType body_with_type {};
|
||||||
return {
|
body.visit(
|
||||||
body.get<NonnullRefPtr<URL::URLSearchParams>>()->to_string().to_byte_buffer(),
|
[&](NonnullRefPtr<URL::URLSearchParams> const& url_search_params) {
|
||||||
"application/x-www-form-urlencoded;charset=UTF-8"
|
body_with_type.body = url_search_params->to_string().to_byte_buffer();
|
||||||
};
|
body_with_type.type = "application/x-www-form-urlencoded;charset=UTF-8";
|
||||||
}
|
},
|
||||||
VERIFY(body.has<String>());
|
[&](String const& string) {
|
||||||
return {
|
body_with_type.body = string.to_byte_buffer();
|
||||||
body.get<String>().to_byte_buffer(),
|
body_with_type.type = "text/plain;charset=UTF-8";
|
||||||
"text/plain;charset=UTF-8"
|
});
|
||||||
};
|
return body_with_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue