diff options
author | Linus Groh <mail@linusgroh.de> | 2022-07-12 18:17:50 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-14 00:42:26 +0100 |
commit | db5c4552386972a6e4b65adbe88d4ed9d2618f69 (patch) | |
tree | 0856c5fcfa2794834719cfcfd3de4ca6b440eee4 /Userland | |
parent | aa852fd9f22c9ca17179a0042a6a4b741433bb64 (diff) | |
download | serenity-db5c4552386972a6e4b65adbe88d4ed9d2618f69.zip |
LibWeb: Use newly added 'Status' Fetch infrastructure in XMLHttpRequest
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 4474c88519..aee9f73894 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -573,6 +573,9 @@ DOM::ExceptionOr<void> XMLHttpRequest::send(Optional<XMLHttpRequestBodyInit> bod // FIXME: in order to properly set ReadyState::HeadersReceived and ReadyState::Loading, // we need to make ResourceLoader give us more detailed updates than just "done" and "error". + // FIXME: In the Fetch spec, which XHR gets its definition of `status` from, the status code is 0-999. + // We could clamp, wrap around (current browser behavior!), or error out. + // See: https://github.com/whatwg/fetch/issues/1142 ResourceLoader::the().load( request, [weak_this = make_weak_ptr()](auto data, auto& response_headers, auto status_code) { diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h index d126689dec..06e751227f 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.h @@ -15,6 +15,7 @@ #include <LibWeb/Bindings/Wrappable.h> #include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/ExceptionOr.h> +#include <LibWeb/Fetch/Infrastructure/HTTP/Statuses.h> #include <LibWeb/MimeSniff/MimeType.h> #include <LibWeb/URL/URLSearchParams.h> #include <LibWeb/XHR/XMLHttpRequestEventTarget.h> @@ -58,7 +59,7 @@ public: using RefCounted::unref; ReadyState ready_state() const { return m_ready_state; }; - unsigned status() const { return m_status; }; + Fetch::Status status() const { return m_status; }; DOM::ExceptionOr<String> response_text() const; DOM::ExceptionOr<JS::Value> response(); Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; } @@ -87,7 +88,7 @@ private: virtual JS::Object* create_wrapper(JS::GlobalObject&) override; void set_ready_state(ReadyState); - void set_status(unsigned status) { m_status = status; } + void set_status(Fetch::Status status) { m_status = status; } void fire_progress_event(String const&, u64, u64); MimeSniff::MimeType get_response_mime_type() const; @@ -104,7 +105,7 @@ private: NonnullRefPtr<HTML::Window> m_window; ReadyState m_ready_state { ReadyState::Unsent }; - unsigned m_status { 0 }; + Fetch::Status m_status { 0 }; bool m_send { false }; u32 m_timeout { 0 }; |