mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibWeb: Use DOMException in XMLHttpRequest::open()
This commit is contained in:
parent
c4d8cce9a2
commit
70878290b9
2 changed files with 8 additions and 10 deletions
|
@ -124,7 +124,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(const String& header,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLHttpRequest::open(const String& method, const String& url)
|
DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url)
|
||||||
{
|
{
|
||||||
// FIXME: Let settingsObject be this’s relevant settings object.
|
// FIXME: Let settingsObject be this’s relevant settings object.
|
||||||
|
|
||||||
|
@ -132,19 +132,15 @@ void XMLHttpRequest::open(const String& method, const String& url)
|
||||||
|
|
||||||
// FIXME: Check that the method matches the method token production. https://tools.ietf.org/html/rfc7230#section-3.1.1
|
// FIXME: Check that the method matches the method token production. https://tools.ietf.org/html/rfc7230#section-3.1.1
|
||||||
|
|
||||||
if (is_forbidden_method(method)) {
|
if (is_forbidden_method(method))
|
||||||
// FIXME: Throw a "SecurityError" DOMException.
|
return DOM::SecurityError::create("Forbidden method, must not be 'CONNECT', 'TRACE', or 'TRACK'");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String normalized_method = normalize_method(method);
|
String normalized_method = normalize_method(method);
|
||||||
|
|
||||||
// FIXME: Pass in settingObject's API base URL and API URL character encoding.
|
// FIXME: Pass in settingObject's API base URL and API URL character encoding.
|
||||||
URL parsed_url(url);
|
URL parsed_url(url);
|
||||||
if (!parsed_url.is_valid()) {
|
if (!parsed_url.is_valid())
|
||||||
// FIXME: Throw a "SyntaxError" DOMException.
|
return DOM::SyntaxError::create("Invalid URL");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parsed_url.host().is_null()) {
|
if (!parsed_url.host().is_null()) {
|
||||||
// FIXME: If the username argument is not null, set the username given parsedURL and username.
|
// FIXME: If the username argument is not null, set the username given parsedURL and username.
|
||||||
|
@ -173,6 +169,7 @@ void XMLHttpRequest::open(const String& method, const String& url)
|
||||||
|
|
||||||
if (m_ready_state != ReadyState::Opened)
|
if (m_ready_state != ReadyState::Opened)
|
||||||
set_ready_state(ReadyState::Opened);
|
set_ready_state(ReadyState::Opened);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send
|
||||||
|
|
|
@ -69,7 +69,8 @@ public:
|
||||||
|
|
||||||
ReadyState ready_state() const { return m_ready_state; };
|
ReadyState ready_state() const { return m_ready_state; };
|
||||||
String response_text() const;
|
String response_text() const;
|
||||||
void open(const String& method, const String& url);
|
|
||||||
|
DOM::ExceptionOr<void> open(const String& method, const String& url);
|
||||||
void send();
|
void send();
|
||||||
|
|
||||||
DOM::ExceptionOr<void> set_request_header(const String& header, const String& value);
|
DOM::ExceptionOr<void> set_request_header(const String& header, const String& value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue