mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:37:44 +00:00
LibWeb: Use newly added 'Status' Fetch infrastructure in XMLHttpRequest
This commit is contained in:
parent
aa852fd9f2
commit
db5c455238
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,
|
// 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".
|
// 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(
|
ResourceLoader::the().load(
|
||||||
request,
|
request,
|
||||||
[weak_this = make_weak_ptr()](auto data, auto& response_headers, auto status_code) {
|
[weak_this = make_weak_ptr()](auto data, auto& response_headers, auto status_code) {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <LibWeb/Bindings/Wrappable.h>
|
#include <LibWeb/Bindings/Wrappable.h>
|
||||||
#include <LibWeb/DOM/EventTarget.h>
|
#include <LibWeb/DOM/EventTarget.h>
|
||||||
#include <LibWeb/DOM/ExceptionOr.h>
|
#include <LibWeb/DOM/ExceptionOr.h>
|
||||||
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Statuses.h>
|
||||||
#include <LibWeb/MimeSniff/MimeType.h>
|
#include <LibWeb/MimeSniff/MimeType.h>
|
||||||
#include <LibWeb/URL/URLSearchParams.h>
|
#include <LibWeb/URL/URLSearchParams.h>
|
||||||
#include <LibWeb/XHR/XMLHttpRequestEventTarget.h>
|
#include <LibWeb/XHR/XMLHttpRequestEventTarget.h>
|
||||||
|
@ -58,7 +59,7 @@ public:
|
||||||
using RefCounted::unref;
|
using RefCounted::unref;
|
||||||
|
|
||||||
ReadyState ready_state() const { return m_ready_state; };
|
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<String> response_text() const;
|
||||||
DOM::ExceptionOr<JS::Value> response();
|
DOM::ExceptionOr<JS::Value> response();
|
||||||
Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; }
|
Bindings::XMLHttpRequestResponseType response_type() const { return m_response_type; }
|
||||||
|
@ -87,7 +88,7 @@ private:
|
||||||
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
virtual JS::Object* create_wrapper(JS::GlobalObject&) override;
|
||||||
|
|
||||||
void set_ready_state(ReadyState);
|
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);
|
void fire_progress_event(String const&, u64, u64);
|
||||||
|
|
||||||
MimeSniff::MimeType get_response_mime_type() const;
|
MimeSniff::MimeType get_response_mime_type() const;
|
||||||
|
@ -104,7 +105,7 @@ private:
|
||||||
NonnullRefPtr<HTML::Window> m_window;
|
NonnullRefPtr<HTML::Window> m_window;
|
||||||
|
|
||||||
ReadyState m_ready_state { ReadyState::Unsent };
|
ReadyState m_ready_state { ReadyState::Unsent };
|
||||||
unsigned m_status { 0 };
|
Fetch::Status m_status { 0 };
|
||||||
bool m_send { false };
|
bool m_send { false };
|
||||||
u32 m_timeout { 0 };
|
u32 m_timeout { 0 };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue