1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

LibWeb/Fetch: Port JS interfaces to new String

Since BodyInit and Headers are tightly coupled to both Request and
Response, I chose to do all of them at once instead of introducing a
bunch of temporary conversion glue code.
This commit is contained in:
Linus Groh 2023-03-02 22:26:12 +00:00
parent f561940e54
commit 7f9ddcf420
13 changed files with 130 additions and 129 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -21,7 +21,7 @@ namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#responseinit
struct ResponseInit {
u16 status;
DeprecatedString status_text;
String status_text;
Optional<HeadersInit> headers;
};
@ -46,14 +46,14 @@ public:
// JS API functions
[[nodiscard]] static JS::NonnullGCPtr<Response> error(JS::VM&);
[[nodiscard]] static WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> redirect(JS::VM&, DeprecatedString const& url, u16 status);
[[nodiscard]] static WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> json(JS::VM&, JS::Value data, ResponseInit const& init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> redirect(JS::VM&, String const& url, u16 status);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> json(JS::VM&, JS::Value data, ResponseInit const& init = {});
[[nodiscard]] Bindings::ResponseType type() const;
[[nodiscard]] DeprecatedString url() const;
[[nodiscard]] WebIDL::ExceptionOr<String> url() const;
[[nodiscard]] bool redirected() const;
[[nodiscard]] u16 status() const;
[[nodiscard]] bool ok() const;
[[nodiscard]] DeprecatedString status_text() const;
[[nodiscard]] WebIDL::ExceptionOr<String> status_text() const;
[[nodiscard]] JS::NonnullGCPtr<Headers> headers() const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone() const;