mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 13:27:35 +00:00
LibWeb: Implement 'Appropriate network error' AO
This commit is contained in:
parent
361ab205fa
commit
c93e6ea0d9
2 changed files with 14 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <LibJS/Heap/Heap.h>
|
#include <LibJS/Heap/Heap.h>
|
||||||
#include <LibJS/Runtime/VM.h>
|
#include <LibJS/Runtime/VM.h>
|
||||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||||
|
#include <LibWeb/Fetch/Infrastructure/FetchParams.h>
|
||||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
||||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||||
|
|
||||||
|
@ -48,6 +49,18 @@ JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm)
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://fetch.spec.whatwg.org/#appropriate-network-error
|
||||||
|
JS::NonnullGCPtr<Response> Response::appropriate_network_error(JS::VM& vm, FetchParams const& fetch_params)
|
||||||
|
{
|
||||||
|
// 1. Assert: fetchParams is canceled.
|
||||||
|
VERIFY(fetch_params.is_canceled());
|
||||||
|
|
||||||
|
// 2. Return an aborted network error if fetchParams is aborted; otherwise return a network error.
|
||||||
|
return fetch_params.is_aborted()
|
||||||
|
? aborted_network_error(vm)
|
||||||
|
: network_error(vm);
|
||||||
|
}
|
||||||
|
|
||||||
// https://fetch.spec.whatwg.org/#concept-aborted-network-error
|
// https://fetch.spec.whatwg.org/#concept-aborted-network-error
|
||||||
bool Response::is_aborted_network_error() const
|
bool Response::is_aborted_network_error() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
[[nodiscard]] static JS::NonnullGCPtr<Response> create(JS::VM&);
|
[[nodiscard]] static JS::NonnullGCPtr<Response> create(JS::VM&);
|
||||||
[[nodiscard]] static JS::NonnullGCPtr<Response> aborted_network_error(JS::VM&);
|
[[nodiscard]] static JS::NonnullGCPtr<Response> aborted_network_error(JS::VM&);
|
||||||
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&);
|
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&);
|
||||||
|
[[nodiscard]] static JS::NonnullGCPtr<Response> appropriate_network_error(JS::VM&, FetchParams const&);
|
||||||
|
|
||||||
virtual ~Response() = default;
|
virtual ~Response() = default;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue