mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:57:44 +00:00
LibWeb/Fetch: Port infrastructure to new String
This commit is contained in:
parent
7f9ddcf420
commit
11023a3c53
20 changed files with 144 additions and 142 deletions
|
@ -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
|
||||
*/
|
||||
|
@ -41,14 +41,15 @@ WebIDL::ExceptionOr<Body> Body::clone() const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#fully-reading-body-as-promise
|
||||
JS::NonnullGCPtr<WebIDL::Promise> Body::fully_read_as_promise() const
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> Body::fully_read_as_promise() const
|
||||
{
|
||||
auto& vm = Bindings::main_thread_vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
// FIXME: Implement the streams spec - this is completely made up for now :^)
|
||||
if (auto const* byte_buffer = m_source.get_pointer<ByteBuffer>()) {
|
||||
auto result = DeprecatedString::copy(*byte_buffer);
|
||||
// FIXME: The buffer may or may not be valid UTF-8.
|
||||
auto result = TRY_OR_THROW_OOM(vm, String::from_utf8(*byte_buffer));
|
||||
return WebIDL::create_resolved_promise(realm, JS::PrimitiveString::create(vm, move(result)));
|
||||
}
|
||||
// Empty, Blob, FormData
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -31,9 +31,9 @@ public:
|
|||
[[nodiscard]] SourceType const& source() const { return m_source; }
|
||||
[[nodiscard]] Optional<u64> const& length() const { return m_length; }
|
||||
|
||||
[[nodiscard]] WebIDL::ExceptionOr<Body> clone() const;
|
||||
WebIDL::ExceptionOr<Body> clone() const;
|
||||
|
||||
[[nodiscard]] JS::NonnullGCPtr<WebIDL::Promise> fully_read_as_promise() const;
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> fully_read_as_promise() const;
|
||||
|
||||
private:
|
||||
// https://fetch.spec.whatwg.org/#concept-body-stream
|
||||
|
|
|
@ -87,7 +87,7 @@ ErrorOr<Optional<ByteBuffer>> HeaderList::get(ReadonlyBytes name) const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split
|
||||
ErrorOr<Optional<Vector<DeprecatedString>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
|
||||
ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
|
||||
{
|
||||
// To get, decode, and split a header name name from header list list, run these steps:
|
||||
|
||||
|
@ -96,14 +96,14 @@ ErrorOr<Optional<Vector<DeprecatedString>>> HeaderList::get_decode_and_split(Rea
|
|||
|
||||
// 2. If value is null, then return null.
|
||||
if (!value.has_value())
|
||||
return Optional<Vector<DeprecatedString>> {};
|
||||
return Optional<Vector<String>> {};
|
||||
|
||||
// 3. Return the result of getting, decoding, and splitting value.
|
||||
return get_decode_and_split_header_value(*value);
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#header-value-get-decode-and-split
|
||||
ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(ReadonlyBytes value)
|
||||
ErrorOr<Optional<Vector<String>>> get_decode_and_split_header_value(ReadonlyBytes value)
|
||||
{
|
||||
// To get, decode, and split a header value value, run these steps:
|
||||
|
||||
|
@ -114,7 +114,7 @@ ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(Re
|
|||
auto lexer = GenericLexer { input };
|
||||
|
||||
// 3. Let values be a list of strings, initially empty.
|
||||
Vector<DeprecatedString> values;
|
||||
Vector<String> values;
|
||||
|
||||
// 4. Let temporaryValue be the empty string.
|
||||
StringBuilder temporary_value_builder;
|
||||
|
@ -123,14 +123,14 @@ ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(Re
|
|||
while (!lexer.is_eof()) {
|
||||
// 1. Append the result of collecting a sequence of code points that are not U+0022 (") or U+002C (,) from input, given position, to temporaryValue.
|
||||
// NOTE: The result might be the empty string.
|
||||
temporary_value_builder.append(lexer.consume_until(is_any_of("\","sv)));
|
||||
TRY(temporary_value_builder.try_append(lexer.consume_until(is_any_of("\","sv))));
|
||||
|
||||
// 2. If position is not past the end of input, then:
|
||||
if (!lexer.is_eof()) {
|
||||
// 1. If the code point at position within input is U+0022 ("), then:
|
||||
if (lexer.peek() == '"') {
|
||||
// 1. Append the result of collecting an HTTP quoted string from input, given position, to temporaryValue.
|
||||
temporary_value_builder.append(collect_an_http_quoted_string(lexer));
|
||||
TRY(temporary_value_builder.try_append(TRY(collect_an_http_quoted_string(lexer))));
|
||||
|
||||
// 2. If position is not past the end of input, then continue.
|
||||
if (!lexer.is_eof())
|
||||
|
@ -147,10 +147,10 @@ ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(Re
|
|||
}
|
||||
|
||||
// 3. Remove all HTTP tab or space from the start and end of temporaryValue.
|
||||
auto temporary_value = temporary_value_builder.to_deprecated_string().trim(HTTP_TAB_OR_SPACE, TrimMode::Both);
|
||||
auto temporary_value = TRY(String::from_utf8(temporary_value_builder.string_view().trim(HTTP_TAB_OR_SPACE, TrimMode::Both)));
|
||||
|
||||
// 4. Append temporaryValue to values.
|
||||
values.append(move(temporary_value));
|
||||
TRY(values.try_append(move(temporary_value)));
|
||||
|
||||
// 5. Set temporaryValue to the empty string.
|
||||
temporary_value_builder.clear();
|
||||
|
@ -301,10 +301,10 @@ ErrorOr<Vector<Header>> HeaderList::sort_and_combine() const
|
|||
Optional<MimeSniff::MimeType> HeaderList::extract_mime_type() const
|
||||
{
|
||||
// 1. Let charset be null.
|
||||
Optional<DeprecatedString> charset;
|
||||
Optional<String> charset;
|
||||
|
||||
// 2. Let essence be null.
|
||||
Optional<DeprecatedString> essence;
|
||||
Optional<String> essence;
|
||||
|
||||
// 3. Let mimeType be null.
|
||||
Optional<MimeSniff::MimeType> mime_type;
|
||||
|
@ -332,21 +332,21 @@ Optional<MimeSniff::MimeType> HeaderList::extract_mime_type() const
|
|||
mime_type = temporary_mime_type;
|
||||
|
||||
// 4. If mimeType’s essence is not essence, then:
|
||||
if (mime_type->essence() != essence) {
|
||||
if (!essence.has_value() || (mime_type->essence() != essence->bytes_as_string_view())) {
|
||||
// 1. Set charset to null.
|
||||
charset = {};
|
||||
|
||||
// 2. If mimeType’s parameters["charset"] exists, then set charset to mimeType’s parameters["charset"].
|
||||
auto charset_it = mime_type->parameters().find("charset"sv);
|
||||
if (charset_it != mime_type->parameters().end())
|
||||
charset = charset_it->value;
|
||||
auto it = mime_type->parameters().find("charset"sv);
|
||||
if (it != mime_type->parameters().end())
|
||||
charset = String::from_deprecated_string(it->value).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 3. Set essence to mimeType’s essence.
|
||||
essence = mime_type->essence();
|
||||
essence = String::from_deprecated_string(mime_type->essence()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
// 5. Otherwise, if mimeType’s parameters["charset"] does not exist, and charset is non-null, set mimeType’s parameters["charset"] to charset.
|
||||
else if (!mime_type->parameters().contains("charset"sv) && charset.has_value()) {
|
||||
mime_type->set_parameter("charset"sv, charset.value());
|
||||
mime_type->set_parameter("charset"sv, charset->to_deprecated_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -7,11 +7,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool contains(ReadonlyBytes) const;
|
||||
[[nodiscard]] ErrorOr<Optional<ByteBuffer>> get(ReadonlyBytes) const;
|
||||
[[nodiscard]] ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split(ReadonlyBytes) const;
|
||||
[[nodiscard]] ErrorOr<Optional<Vector<String>>> get_decode_and_split(ReadonlyBytes) const;
|
||||
[[nodiscard]] ErrorOr<void> append(Header);
|
||||
void delete_(ReadonlyBytes name);
|
||||
[[nodiscard]] ErrorOr<void> set(Header);
|
||||
|
@ -62,7 +62,7 @@ struct RangeHeaderValue {
|
|||
struct ExtractHeaderParseFailure {
|
||||
};
|
||||
|
||||
[[nodiscard]] ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split_header_value(ReadonlyBytes);
|
||||
[[nodiscard]] ErrorOr<Optional<Vector<String>>> get_decode_and_split_header_value(ReadonlyBytes);
|
||||
[[nodiscard]] ErrorOr<OrderedHashTable<ByteBuffer>> convert_header_names_to_a_sorted_lowercase_set(Span<ReadonlyBytes>);
|
||||
[[nodiscard]] bool is_header_name(ReadonlyBytes);
|
||||
[[nodiscard]] bool is_header_value(ReadonlyBytes);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -177,21 +177,21 @@ bool Request::has_redirect_tainted_origin() const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#serializing-a-request-origin
|
||||
DeprecatedString Request::serialize_origin() const
|
||||
ErrorOr<String> Request::serialize_origin() const
|
||||
{
|
||||
// 1. If request has a redirect-tainted origin, then return "null".
|
||||
if (has_redirect_tainted_origin())
|
||||
return "null"sv;
|
||||
return "null"_string;
|
||||
|
||||
// 2. Return request’s origin, serialized.
|
||||
return m_origin.get<HTML::Origin>().serialize();
|
||||
return String::from_deprecated_string(m_origin.get<HTML::Origin>().serialize());
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#byte-serializing-a-request-origin
|
||||
ErrorOr<ByteBuffer> Request::byte_serialize_origin() const
|
||||
{
|
||||
// Byte-serializing a request origin, given a request request, is to return the result of serializing a request origin with request, isomorphic encoded.
|
||||
return ByteBuffer::copy(serialize_origin().bytes());
|
||||
return ByteBuffer::copy(TRY(serialize_origin()).bytes());
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-clone
|
||||
|
@ -260,14 +260,14 @@ ErrorOr<void> Request::add_range_header(u64 first, Optional<u64> const& last)
|
|||
auto range_value = MUST(ByteBuffer::copy("bytes"sv.bytes()));
|
||||
|
||||
// 3. Serialize and isomorphic encode first, and append the result to rangeValue.
|
||||
TRY(range_value.try_append(DeprecatedString::number(first).bytes()));
|
||||
TRY(range_value.try_append(TRY(String::number(first)).bytes()));
|
||||
|
||||
// 4. Append 0x2D (-) to rangeValue.
|
||||
TRY(range_value.try_append('-'));
|
||||
|
||||
// 5. If last is given, then serialize and isomorphic encode it, and append the result to rangeValue.
|
||||
if (last.has_value())
|
||||
TRY(range_value.try_append(DeprecatedString::number(*last).bytes()));
|
||||
TRY(range_value.try_append(TRY(String::number(*last)).bytes()));
|
||||
|
||||
// 6. Append (`Range`, rangeValue) to request’s header list.
|
||||
auto header = Header {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -7,10 +7,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -186,8 +186,8 @@ public:
|
|||
[[nodiscard]] ReservedClientType& reserved_client() { return m_reserved_client; }
|
||||
void set_reserved_client(ReservedClientType reserved_client) { m_reserved_client = move(reserved_client); }
|
||||
|
||||
[[nodiscard]] DeprecatedString const& replaces_client_id() const { return m_replaces_client_id; }
|
||||
void set_replaces_client_id(DeprecatedString replaces_client_id) { m_replaces_client_id = move(replaces_client_id); }
|
||||
[[nodiscard]] String const& replaces_client_id() const { return m_replaces_client_id; }
|
||||
void set_replaces_client_id(String replaces_client_id) { m_replaces_client_id = move(replaces_client_id); }
|
||||
|
||||
[[nodiscard]] WindowType const& window() const { return m_window; }
|
||||
void set_window(WindowType window) { m_window = move(window); }
|
||||
|
@ -234,11 +234,11 @@ public:
|
|||
[[nodiscard]] RedirectMode redirect_mode() const { return m_redirect_mode; }
|
||||
void set_redirect_mode(RedirectMode redirect_mode) { m_redirect_mode = redirect_mode; }
|
||||
|
||||
[[nodiscard]] DeprecatedString const& integrity_metadata() const { return m_integrity_metadata; }
|
||||
void set_integrity_metadata(DeprecatedString integrity_metadata) { m_integrity_metadata = move(integrity_metadata); }
|
||||
[[nodiscard]] String const& integrity_metadata() const { return m_integrity_metadata; }
|
||||
void set_integrity_metadata(String integrity_metadata) { m_integrity_metadata = move(integrity_metadata); }
|
||||
|
||||
[[nodiscard]] DeprecatedString const& cryptographic_nonce_metadata() const { return m_cryptographic_nonce_metadata; }
|
||||
void set_cryptographic_nonce_metadata(DeprecatedString cryptographic_nonce_metadata) { m_cryptographic_nonce_metadata = move(cryptographic_nonce_metadata); }
|
||||
[[nodiscard]] String const& cryptographic_nonce_metadata() const { return m_cryptographic_nonce_metadata; }
|
||||
void set_cryptographic_nonce_metadata(String cryptographic_nonce_metadata) { m_cryptographic_nonce_metadata = move(cryptographic_nonce_metadata); }
|
||||
|
||||
[[nodiscard]] Optional<ParserMetadata> const& parser_metadata() const { return m_parser_metadata; }
|
||||
void set_parser_metadata(Optional<ParserMetadata> parser_metadata) { m_parser_metadata = move(parser_metadata); }
|
||||
|
@ -294,7 +294,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool has_redirect_tainted_origin() const;
|
||||
|
||||
[[nodiscard]] DeprecatedString serialize_origin() const;
|
||||
[[nodiscard]] ErrorOr<String> serialize_origin() const;
|
||||
[[nodiscard]] ErrorOr<ByteBuffer> byte_serialize_origin() const;
|
||||
|
||||
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> clone(JS::VM&) const;
|
||||
|
@ -352,7 +352,7 @@ private:
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-replaces-client-id
|
||||
// A request has an associated replaces client id (a string). Unless stated otherwise it is the empty string.
|
||||
DeprecatedString m_replaces_client_id { DeprecatedString::empty() };
|
||||
String m_replaces_client_id;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-window
|
||||
// A request has an associated window ("no-window", "client", or an environment settings object whose global object
|
||||
|
@ -444,12 +444,12 @@ private:
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-integrity-metadata
|
||||
// A request has associated integrity metadata (a string). Unless stated otherwise, it is the empty string.
|
||||
DeprecatedString m_integrity_metadata { DeprecatedString::empty() };
|
||||
String m_integrity_metadata;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-nonce-metadata
|
||||
// A request has associated cryptographic nonce metadata (a string). Unless stated otherwise, it is the empty
|
||||
// string.
|
||||
DeprecatedString m_cryptographic_nonce_metadata { DeprecatedString::empty() };
|
||||
String m_cryptographic_nonce_metadata;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-request-parser-metadata
|
||||
// A request has associated parser metadata which is the empty string, "parser-inserted", or
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -37,14 +37,14 @@ JS::NonnullGCPtr<Response> Response::create(JS::VM& vm)
|
|||
// A network error is a response whose status is always 0, status message is always
|
||||
// the empty byte sequence, header list is always empty, and body is always null.
|
||||
|
||||
JS::NonnullGCPtr<Response> Response::aborted_network_error(JS::VM& vm)
|
||||
ErrorOr<JS::NonnullGCPtr<Response>> Response::aborted_network_error(JS::VM& vm)
|
||||
{
|
||||
auto response = network_error(vm, "Fetch has been aborted"sv);
|
||||
auto response = network_error(vm, TRY("Fetch has been aborted"_string));
|
||||
response->set_aborted(true);
|
||||
return response;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, DeprecatedString message)
|
||||
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, String message)
|
||||
{
|
||||
dbgln_if(WEB_FETCH_DEBUG, "Fetch: Creating network error response with message: {}", message);
|
||||
auto response = Response::create(vm);
|
||||
|
@ -56,15 +56,15 @@ JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, DeprecatedString
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#appropriate-network-error
|
||||
JS::NonnullGCPtr<Response> Response::appropriate_network_error(JS::VM& vm, FetchParams const& fetch_params)
|
||||
ErrorOr<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, "Fetch has been terminated"sv);
|
||||
? TRY(aborted_network_error(vm))
|
||||
: network_error(vm, TRY("Fetch has been terminated"_string));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-aborted-network-error
|
||||
|
@ -94,7 +94,7 @@ Optional<AK::URL const&> Response::url() const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-response-location-url
|
||||
ErrorOr<Optional<AK::URL>> Response::location_url(Optional<DeprecatedString> const& request_fragment) const
|
||||
ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& request_fragment) const
|
||||
{
|
||||
// The location URL of a response response, given null or an ASCII string requestFragment, is the value returned by the following steps. They return null, failure, or a URL.
|
||||
|
||||
|
@ -120,7 +120,7 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<DeprecatedString> con
|
|||
|
||||
// 4. If location is a URL whose fragment is null, then set location’s fragment to requestFragment.
|
||||
if (location.fragment().is_null())
|
||||
location.set_fragment(request_fragment.value_or({}));
|
||||
location.set_fragment(request_fragment.has_value() ? request_fragment->to_deprecated_string() : DeprecatedString {});
|
||||
|
||||
// 5. Return location.
|
||||
return location;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -50,9 +50,9 @@ public:
|
|||
};
|
||||
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> create(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> aborted_network_error(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, DeprecatedString message);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> appropriate_network_error(JS::VM&, FetchParams const&);
|
||||
static ErrorOr<JS::NonnullGCPtr<Response>> aborted_network_error(JS::VM&);
|
||||
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, String message);
|
||||
static ErrorOr<JS::NonnullGCPtr<Response>> appropriate_network_error(JS::VM&, FetchParams const&);
|
||||
|
||||
virtual ~Response() = default;
|
||||
|
||||
|
@ -104,12 +104,12 @@ public:
|
|||
[[nodiscard]] bool is_network_error() const;
|
||||
|
||||
[[nodiscard]] Optional<AK::URL const&> url() const;
|
||||
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<DeprecatedString> const& request_fragment) const;
|
||||
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<String> const& request_fragment) const;
|
||||
|
||||
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone(JS::VM&) const;
|
||||
|
||||
// Non-standard
|
||||
Optional<DeprecatedString> const& network_error_message() const { return m_network_error_message; }
|
||||
Optional<String> const& network_error_message() const { return m_network_error_message; }
|
||||
|
||||
protected:
|
||||
explicit Response(JS::NonnullGCPtr<HeaderList>);
|
||||
|
@ -177,7 +177,7 @@ private:
|
|||
bool m_has_cross_origin_redirects { false };
|
||||
|
||||
// Non-standard
|
||||
Optional<DeprecatedString> m_network_error_message;
|
||||
Optional<String> m_network_error_message;
|
||||
};
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-filtered-response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue