summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2022-07-14 17:28:39 +0200
committerLinus Groh <mail@linusgroh.de>2022-07-18 14:57:58 +0100
commitbc4ccadcac7ca197cc73561d53a5cd11f3b7201b (patch)
tree65e14b68e704e4600edebc126cbfde3187fe110f /Userland
parent48b59aaeb1e66093bcc680c05c83e9a3d38173db (diff)
downloadserenity-bc4ccadcac7ca197cc73561d53a5cd11f3b7201b.zip
LibWeb: XHR::extra_body() rewrite to use Variant::visit()
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index 2b4b0145b4..ca92d34dd8 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -313,17 +313,17 @@ Optional<MimeSniff::MimeType> XMLHttpRequest::extract_mime_type(Fetch::HeaderLis
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
static XMLHttpRequest::BodyWithType extract_body(XMLHttpRequestBodyInit const& body)
{
- if (body.has<NonnullRefPtr<URL::URLSearchParams>>()) {
- return {
- body.get<NonnullRefPtr<URL::URLSearchParams>>()->to_string().to_byte_buffer(),
- "application/x-www-form-urlencoded;charset=UTF-8"
- };
- }
- VERIFY(body.has<String>());
- return {
- body.get<String>().to_byte_buffer(),
- "text/plain;charset=UTF-8"
- };
+ XMLHttpRequest::BodyWithType body_with_type {};
+ body.visit(
+ [&](NonnullRefPtr<URL::URLSearchParams> const& url_search_params) {
+ body_with_type.body = url_search_params->to_string().to_byte_buffer();
+ body_with_type.type = "application/x-www-form-urlencoded;charset=UTF-8";
+ },
+ [&](String const& string) {
+ body_with_type.body = string.to_byte_buffer();
+ body_with_type.type = "text/plain;charset=UTF-8";
+ });
+ return body_with_type;
}
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-setrequestheader