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 XMLHttpRequest::send(Optional 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 #include #include +#include #include #include #include @@ -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 response_text() const; DOM::ExceptionOr 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 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 };