1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:27:43 +00:00

LibWeb: Don't send a request body in XMLHttpRequest GET or HEAD

This commit is contained in:
Andreas Kling 2021-10-04 00:06:48 +02:00
parent 0cb4d48283
commit a7b1c7eb16
2 changed files with 5 additions and 5 deletions

View file

@ -161,7 +161,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String&
} }
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send // 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) if (m_ready_state != ReadyState::Opened)
return DOM::InvalidStateError::create("XHR readyState is not 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) if (m_send)
return DOM::InvalidStateError::create("XHR send() flag is already set"); return DOM::InvalidStateError::create("XHR send() flag is already set");
// FIXME: If thiss request method is `GET` or `HEAD`, then set body to null. // If thiss request method is `GET` or `HEAD`, then set body to null.
if (m_method.is_one_of("GET"sv, "HEAD"sv))
// FIXME: If body is not null, then: body = {};
AK::URL request_url = m_window->associated_document().parse_url(m_url.to_string()); 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); dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url);

View file

@ -52,7 +52,7 @@ public:
String response_text() const; String response_text() const;
DOM::ExceptionOr<void> open(const String& method, const String& url); 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); DOM::ExceptionOr<void> set_request_header(const String& header, const String& value);