diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-04 00:06:48 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-04 00:06:48 +0200 |
commit | a7b1c7eb16ea531bd845905df0f3c841f3e6dd87 (patch) | |
tree | ac8eb3d6f418d0cded8d508d90491232020b9f6f /Userland/Libraries/LibWeb | |
parent | 0cb4d482834c3150e99587f571f95c12823f773e (diff) | |
download | serenity-a7b1c7eb16ea531bd845905df0f3c841f3e6dd87.zip |
LibWeb: Don't send a request body in XMLHttpRequest GET or HEAD
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index d778e7338a..377109270a 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -161,7 +161,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& } // https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send -DOM::ExceptionOr<void> XMLHttpRequest::send(String const& body) +DOM::ExceptionOr<void> XMLHttpRequest::send(String body) { if (m_ready_state != ReadyState::Opened) return DOM::InvalidStateError::create("XHR readyState is not OPENED"); @@ -169,9 +169,9 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(String const& body) if (m_send) return DOM::InvalidStateError::create("XHR send() flag is already set"); - // FIXME: If this’s request method is `GET` or `HEAD`, then set body to null. - - // FIXME: If body is not null, then: + // If this’s request method is `GET` or `HEAD`, then set body to null. + if (m_method.is_one_of("GET"sv, "HEAD"sv)) + body = {}; AK::URL request_url = m_window->associated_document().parse_url(m_url.to_string()); dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url); diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index ae47e556cc..1905f169ae 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -52,7 +52,7 @@ public: String response_text() const; DOM::ExceptionOr<void> open(const String& method, const String& url); - DOM::ExceptionOr<void> send(String const& body); + DOM::ExceptionOr<void> send(String body); DOM::ExceptionOr<void> set_request_header(const String& header, const String& value); |