mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Use newly added 'Status' Fetch infrastructure in XMLHttpRequest
This commit is contained in:
parent
aa852fd9f2
commit
db5c455238
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/db5c455238 Pull-request: https://github.com/SerenityOS/serenity/pull/14568 Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 7 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Reference in a new issue