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

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -107,7 +107,7 @@ WebIDL::ExceptionOr<JS::Value> package_data(JS::Realm& realm, ByteBuffer bytes,
case PackageDataType::Blob: {
// Return a Blob whose contents are bytes and type attribute is mimeType.
// NOTE: If extracting the mime type returns failure, other browsers set it to an empty string - not sure if that's spec'd.
auto mime_type_string = mime_type.has_value() ? mime_type->serialized() : String::empty();
auto mime_type_string = mime_type.has_value() ? mime_type->serialized() : DeprecatedString::empty();
return FileAPI::Blob::create(realm, move(bytes), move(mime_type_string));
}
case PackageDataType::FormData:
@ -134,7 +134,7 @@ WebIDL::ExceptionOr<JS::Value> package_data(JS::Realm& realm, ByteBuffer bytes,
return Infra::parse_json_bytes_to_javascript_value(vm, bytes);
case PackageDataType::Text:
// Return the result of running UTF-8 decode on bytes.
return JS::js_string(vm, String::copy(bytes));
return JS::js_string(vm, DeprecatedString::copy(bytes));
default:
VERIFY_NOT_REACHED();
}
@ -152,7 +152,7 @@ JS::NonnullGCPtr<JS::Promise> consume_body(JS::Realm& realm, BodyMixin const& ob
}
// 2. Let promise be a promise resolved with an empty byte sequence.
auto promise = WebIDL::create_resolved_promise(realm, JS::js_string(vm, String::empty()));
auto promise = WebIDL::create_resolved_promise(realm, JS::js_string(vm, DeprecatedString::empty()));
// 3. If objects body is non-null, then set promise to the result of fully reading body as promise given objects body.
auto const& body = object.body_impl();

View file

@ -92,8 +92,8 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
type = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy("application/x-www-form-urlencoded;charset=UTF-8"sv.bytes()));
return {};
},
[&](String const& scalar_value_string) -> WebIDL::ExceptionOr<void> {
// NOTE: AK::String is always UTF-8.
[&](DeprecatedString const& scalar_value_string) -> WebIDL::ExceptionOr<void> {
// NOTE: AK::DeprecatedString is always UTF-8.
// Set source to the UTF-8 encoding of object.
source = scalar_value_string.to_byte_buffer();
// Set type to `text/plain;charset=UTF-8`.

View file

@ -14,9 +14,9 @@
namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#bodyinit
using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, String>;
using BodyInit = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, DeprecatedString>;
using BodyInitOrReadableBytes = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, String, ReadonlyBytes>;
using BodyInitOrReadableBytes = Variant<JS::Handle<Streams::ReadableStream>, JS::Handle<FileAPI::Blob>, JS::Handle<JS::Object>, JS::Handle<URL::URLSearchParams>, DeprecatedString, ReadonlyBytes>;
WebIDL::ExceptionOr<Infrastructure::BodyWithType> safely_extract_body(JS::Realm&, BodyInitOrReadableBytes const&);
WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm&, BodyInitOrReadableBytes const&, bool keepalive = false);

View file

@ -1151,7 +1151,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// 8. If contentLength is non-null, then set contentLengthHeaderValue to contentLength, serialized and
// isomorphic encoded.
if (content_length.has_value())
content_length_header_value = MUST(ByteBuffer::copy(String::number(*content_length).bytes()));
content_length_header_value = MUST(ByteBuffer::copy(DeprecatedString::number(*content_length).bytes()));
// 9. If contentLengthHeaderValue is non-null, then append (`Content-Length`, contentLengthHeaderValue) to
// httpRequests header list.
@ -1267,10 +1267,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers.
auto document = Bindings::host_defined_environment_settings_object(realm).responsible_document();
if (!document)
return String::empty();
return DeprecatedString::empty();
auto* page = document->page();
if (!page)
return String::empty();
return DeprecatedString::empty();
return page->client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http);
})();
@ -1284,7 +1284,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// 2. If httpRequests header list does not contain `Authorization`, then:
if (!http_request->header_list()->contains("Authorization"sv.bytes())) {
// 1. Let authorizationValue be null.
auto authorization_value = Optional<String> {};
auto authorization_value = Optional<DeprecatedString> {};
// 2. If theres an authentication entry for httpRequest and either httpRequests use-URL-credentials
// flag is unset or httpRequests current URL does not include credentials, then set
@ -1297,7 +1297,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// true, set authorizationValue to httpRequests current URL, converted to an `Authorization` value.
else if (http_request->current_url().includes_credentials() && is_authentication_fetch == IsAuthenticationFetch::Yes) {
auto const& url = http_request->current_url();
authorization_value = encode_base64(String::formatted("{}:{}", url.username(), url.password()).bytes());
authorization_value = encode_base64(DeprecatedString::formatted("{}:{}", url.username(), url.password()).bytes());
}
// 4. If authorizationValue is non-null, then append (`Authorization`, authorizationValue) to
@ -1451,8 +1451,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// FIXME: 2. Let username and password be the result of prompting the end user for a username and password,
// respectively, in requests window.
dbgln("Fetch: Username/password prompt is not implemented, using empty strings. This request will probably fail.");
auto username = String::empty();
auto password = String::empty();
auto username = DeprecatedString::empty();
auto password = DeprecatedString::empty();
// 3. Set the username given requests current URL and username.
request->current_url().set_username(move(username));
@ -1569,9 +1569,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load
auto request = fetch_params.request();
auto load_request = LoadRequest::create_for_url_on_page(request->current_url(), nullptr);
load_request.set_method(String::copy(request->method()));
load_request.set_method(DeprecatedString::copy(request->method()));
for (auto const& header : *request->header_list())
load_request.set_header(String::copy(header.name), String::copy(header.value));
load_request.set_header(DeprecatedString::copy(header.name), DeprecatedString::copy(header.value));
if (auto const* body = request->body().get_pointer<Infrastructure::Body>()) {
TRY(body->source().visit(
[&](ByteBuffer const& byte_buffer) -> WebIDL::ExceptionOr<void> {

View file

@ -44,7 +44,7 @@ void Headers::visit_edges(JS::Cell::Visitor& visitor)
}
// https://fetch.spec.whatwg.org/#dom-headers-append
WebIDL::ExceptionOr<void> Headers::append(String const& name_string, String const& value_string)
WebIDL::ExceptionOr<void> Headers::append(DeprecatedString const& name_string, DeprecatedString const& value_string)
{
// The append(name, value) method steps are to append (name, value) to this.
auto header = Infrastructure::Header {
@ -56,7 +56,7 @@ WebIDL::ExceptionOr<void> Headers::append(String const& name_string, String cons
}
// https://fetch.spec.whatwg.org/#dom-headers-delete
WebIDL::ExceptionOr<void> Headers::delete_(String const& name_string)
WebIDL::ExceptionOr<void> Headers::delete_(DeprecatedString const& name_string)
{
// The delete(name) method steps are:
auto name = name_string.bytes();
@ -96,7 +96,7 @@ WebIDL::ExceptionOr<void> Headers::delete_(String const& name_string)
}
// https://fetch.spec.whatwg.org/#dom-headers-get
WebIDL::ExceptionOr<String> Headers::get(String const& name_string)
WebIDL::ExceptionOr<DeprecatedString> Headers::get(DeprecatedString const& name_string)
{
// The get(name) method steps are:
auto name = name_string.bytes();
@ -107,12 +107,12 @@ WebIDL::ExceptionOr<String> Headers::get(String const& name_string)
// 2. Return the result of getting name from thiss header list.
auto byte_buffer = TRY_OR_RETURN_OOM(realm(), m_header_list->get(name));
// FIXME: Teach BindingsGenerator about Optional<String>
return byte_buffer.has_value() ? String { byte_buffer->span() } : String {};
// FIXME: Teach BindingsGenerator about Optional<DeprecatedString>
return byte_buffer.has_value() ? DeprecatedString { byte_buffer->span() } : DeprecatedString {};
}
// https://fetch.spec.whatwg.org/#dom-headers-has
WebIDL::ExceptionOr<bool> Headers::has(String const& name_string)
WebIDL::ExceptionOr<bool> Headers::has(DeprecatedString const& name_string)
{
// The has(name) method steps are:
auto name = name_string.bytes();
@ -126,7 +126,7 @@ WebIDL::ExceptionOr<bool> Headers::has(String const& name_string)
}
// https://fetch.spec.whatwg.org/#dom-headers-set
WebIDL::ExceptionOr<void> Headers::set(String const& name_string, String const& value_string)
WebIDL::ExceptionOr<void> Headers::set(DeprecatedString const& name_string, DeprecatedString const& value_string)
{
// The set(name, value) method steps are:
auto name = name_string.bytes();
@ -278,7 +278,7 @@ WebIDL::ExceptionOr<void> Headers::fill(HeadersInit const& object)
// To fill a Headers object headers with a given object object, run these steps:
return object.visit(
// 1. If object is a sequence, then for each header in object:
[this](Vector<Vector<String>> const& object) -> WebIDL::ExceptionOr<void> {
[this](Vector<Vector<DeprecatedString>> const& object) -> WebIDL::ExceptionOr<void> {
for (auto const& entry : object) {
// 1. If header does not contain exactly two items, then throw a TypeError.
if (entry.size() != 2)
@ -291,7 +291,7 @@ WebIDL::ExceptionOr<void> Headers::fill(HeadersInit const& object)
return {};
},
// 2. Otherwise, object is a record, then for each key → value in object, append (key, value) to headers.
[this](OrderedHashMap<String, String> const& object) -> WebIDL::ExceptionOr<void> {
[this](OrderedHashMap<DeprecatedString, DeprecatedString> const& object) -> WebIDL::ExceptionOr<void> {
for (auto const& entry : object) {
auto header = TRY_OR_RETURN_OOM(realm(), Infrastructure::Header::from_string_pair(entry.key, entry.value));
TRY(append(move(header)));

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
@ -17,7 +17,7 @@
namespace Web::Fetch {
using HeadersInit = Variant<Vector<Vector<String>>, OrderedHashMap<String, String>>;
using HeadersInit = Variant<Vector<Vector<DeprecatedString>>, OrderedHashMap<DeprecatedString, DeprecatedString>>;
// https://fetch.spec.whatwg.org/#headers-class
class Headers final : public Bindings::PlatformObject {
@ -46,13 +46,13 @@ public:
// JS API functions
WebIDL::ExceptionOr<void> append(Infrastructure::Header);
WebIDL::ExceptionOr<void> append(String const& name, String const& value);
WebIDL::ExceptionOr<void> delete_(String const& name);
WebIDL::ExceptionOr<String> get(String const& name);
WebIDL::ExceptionOr<bool> has(String const& name);
WebIDL::ExceptionOr<void> set(String const& name, String const& value);
WebIDL::ExceptionOr<void> append(DeprecatedString const& name, DeprecatedString const& value);
WebIDL::ExceptionOr<void> delete_(DeprecatedString const& name);
WebIDL::ExceptionOr<DeprecatedString> get(DeprecatedString const& name);
WebIDL::ExceptionOr<bool> has(DeprecatedString const& name);
WebIDL::ExceptionOr<void> set(DeprecatedString const& name, DeprecatedString const& value);
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(String const&, String const&)>;
using ForEachCallback = Function<JS::ThrowCompletionOr<void>(DeprecatedString const&, DeprecatedString const&)>;
JS::ThrowCompletionOr<void> for_each(ForEachCallback);
private:

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
@ -49,9 +49,9 @@ public:
[[nodiscard]] JS::GCPtr<ConnectionTimingInfo> final_connection_timing_info() const { return m_final_connection_timing_info; }
void set_final_connection_timing_info(JS::GCPtr<ConnectionTimingInfo> final_connection_timing_info) { m_final_connection_timing_info = final_connection_timing_info; }
[[nodiscard]] Vector<String>& server_timing_headers() { return m_server_timing_headers; }
[[nodiscard]] Vector<String> const& server_timing_headers() const { return m_server_timing_headers; }
void set_server_timing_headers(Vector<String> server_timing_headers) { m_server_timing_headers = move(server_timing_headers); }
[[nodiscard]] Vector<DeprecatedString>& server_timing_headers() { return m_server_timing_headers; }
[[nodiscard]] Vector<DeprecatedString> const& server_timing_headers() const { return m_server_timing_headers; }
void set_server_timing_headers(Vector<DeprecatedString> server_timing_headers) { m_server_timing_headers = move(server_timing_headers); }
[[nodiscard]] bool render_blocking() const { return m_render_blocking; }
void set_render_blocking(bool render_blocking) { m_render_blocking = render_blocking; }
@ -109,7 +109,7 @@ private:
// https://fetch.spec.whatwg.org/#fetch-timing-info-server-timing-headers
// server-timing headers (default « »)
// A list of strings.
Vector<String> m_server_timing_headers;
Vector<DeprecatedString> m_server_timing_headers;
// https://fetch.spec.whatwg.org/#fetch-timing-info-render-blocking
// render-blocking (default false)

View file

@ -4,15 +4,15 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/GenericLexer.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibWeb/Fetch/Infrastructure/HTTP.h>
namespace Web::Fetch::Infrastructure {
// https://fetch.spec.whatwg.org/#collect-an-http-quoted-string
String collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value)
DeprecatedString collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value)
{
// To collect an HTTP quoted string from a string input, given a position variable position and optionally an extract-value flag, run these steps:
// 1. Let positionStart be position.

View file

@ -37,6 +37,6 @@ enum class HttpQuotedStringExtractValue {
Yes,
};
[[nodiscard]] String collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value = HttpQuotedStringExtractValue::No);
[[nodiscard]] DeprecatedString collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value = HttpQuotedStringExtractValue::No);
}

View file

@ -48,7 +48,7 @@ JS::NonnullGCPtr<JS::PromiseCapability> Body::fully_read_as_promise() const
// FIXME: Implement the streams spec - this is completely made up for now :^)
if (auto const* byte_buffer = m_source.get_pointer<ByteBuffer>()) {
auto result = String::copy(*byte_buffer);
auto result = DeprecatedString::copy(*byte_buffer);
return WebIDL::create_resolved_promise(realm, JS::js_string(vm, move(result)));
}
// Empty, Blob, FormData

View file

@ -86,7 +86,7 @@ ErrorOr<Optional<ByteBuffer>> HeaderList::get(ReadonlyBytes name) const
}
// https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split
ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
ErrorOr<Optional<Vector<DeprecatedString>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
{
// To get, decode, and split a header name name from header list list, run these steps:
@ -95,7 +95,7 @@ ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes
// 2. If initialValue is null, then return null.
if (!initial_value.has_value())
return Optional<Vector<String>> {};
return Optional<Vector<DeprecatedString>> {};
// 3. Let input be the result of isomorphic decoding initialValue.
auto input = StringView { *initial_value };
@ -104,7 +104,7 @@ ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes
auto lexer = GenericLexer { input };
// 5. Let values be a list of strings, initially empty.
Vector<String> values;
Vector<DeprecatedString> values;
// 6. Let value be the empty string.
StringBuilder value_builder;
@ -273,10 +273,10 @@ ErrorOr<Vector<Header>> HeaderList::sort_and_combine() const
Optional<MimeSniff::MimeType> HeaderList::extract_mime_type() const
{
// 1. Let charset be null.
Optional<String> charset;
Optional<DeprecatedString> charset;
// 2. Let essence be null.
Optional<String> essence;
Optional<DeprecatedString> essence;
// 3. Let mimeType be null.
Optional<MimeSniff::MimeType> mime_type;

View file

@ -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>
@ -44,7 +44,7 @@ public:
[[nodiscard]] bool contains(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<ByteBuffer>> get(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<Vector<String>>> get_decode_and_split(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<void> append(Header);
void delete_(ReadonlyBytes name);
[[nodiscard]] ErrorOr<void> set(Header);

View file

@ -177,7 +177,7 @@ bool Request::has_redirect_tainted_origin() const
}
// https://fetch.spec.whatwg.org/#serializing-a-request-origin
String Request::serialize_origin() const
DeprecatedString Request::serialize_origin() const
{
// 1. If request has a redirect-tainted origin, then return "null".
if (has_redirect_tainted_origin())
@ -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(String::number(first).bytes()));
TRY(range_value.try_append(DeprecatedString::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(String::number(*last).bytes()));
TRY(range_value.try_append(DeprecatedString::number(*last).bytes()));
// 6. Append (`Range`, rangeValue) to requests header list.
auto header = Header {

View file

@ -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>
@ -185,8 +185,8 @@ public:
[[nodiscard]] ReservedClientType& reserved_client() { return m_reserved_client; }
void set_reserved_client(ReservedClientType reserved_client) { m_reserved_client = move(reserved_client); }
[[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]] 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]] WindowType const& window() const { return m_window; }
void set_window(WindowType window) { m_window = move(window); }
@ -233,11 +233,11 @@ public:
[[nodiscard]] RedirectMode redirect_mode() const { return m_redirect_mode; }
void set_redirect_mode(RedirectMode redirect_mode) { m_redirect_mode = redirect_mode; }
[[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& integrity_metadata() const { return m_integrity_metadata; }
void set_integrity_metadata(DeprecatedString integrity_metadata) { m_integrity_metadata = move(integrity_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]] 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]] Optional<ParserMetadata> const& parser_metadata() const { return m_parser_metadata; }
void set_parser_metadata(Optional<ParserMetadata> parser_metadata) { m_parser_metadata = move(parser_metadata); }
@ -293,7 +293,7 @@ public:
[[nodiscard]] bool has_redirect_tainted_origin() const;
[[nodiscard]] String serialize_origin() const;
[[nodiscard]] DeprecatedString serialize_origin() const;
[[nodiscard]] ErrorOr<ByteBuffer> byte_serialize_origin() const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> clone(JS::VM&) const;
@ -351,7 +351,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.
String m_replaces_client_id { String::empty() };
DeprecatedString m_replaces_client_id { DeprecatedString::empty() };
// 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
@ -443,12 +443,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.
String m_integrity_metadata { String::empty() };
DeprecatedString m_integrity_metadata { DeprecatedString::empty() };
// 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.
String m_cryptographic_nonce_metadata { String::empty() };
DeprecatedString m_cryptographic_nonce_metadata { DeprecatedString::empty() };
// https://fetch.spec.whatwg.org/#concept-request-parser-metadata
// A request has associated parser metadata which is the empty string, "parser-inserted", or

View file

@ -43,7 +43,7 @@ JS::NonnullGCPtr<Response> Response::aborted_network_error(JS::VM& vm)
return response;
}
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, String message)
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, DeprecatedString message)
{
dbgln_if(WEB_FETCH_DEBUG, "Fetch: Creating network error response with message: {}", message);
auto response = Response::create(vm);
@ -93,7 +93,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<String> const& request_fragment) const
ErrorOr<Optional<AK::URL>> Response::location_url(Optional<DeprecatedString> 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.

View file

@ -50,7 +50,7 @@ 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&, String message);
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, DeprecatedString message);
[[nodiscard]] static JS::NonnullGCPtr<Response> appropriate_network_error(JS::VM&, FetchParams const&);
virtual ~Response() = default;
@ -103,12 +103,12 @@ public:
[[nodiscard]] bool is_network_error() const;
[[nodiscard]] Optional<AK::URL const&> url() const;
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<String> const& request_fragment) const;
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<DeprecatedString> const& request_fragment) const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone(JS::VM&) const;
// Non-standard
Optional<String> const& network_error_message() const { return m_network_error_message; }
Optional<DeprecatedString> const& network_error_message() const { return m_network_error_message; }
protected:
explicit Response(JS::NonnullGCPtr<HeaderList>);
@ -176,7 +176,7 @@ private:
bool m_has_cross_origin_redirects { false };
// Non-standard
Optional<String> m_network_error_message;
Optional<DeprecatedString> m_network_error_message;
};
// https://fetch.spec.whatwg.org/#concept-filtered-response

View file

@ -111,9 +111,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
DOM::AbortSignal const* input_signal = nullptr;
// 5. If input is a string, then:
if (input.has<String>()) {
if (input.has<DeprecatedString>()) {
// 1. Let parsedURL be the result of parsing input with baseURL.
auto parsed_url = URLParser::parse(input.get<String>(), &base_url);
auto parsed_url = URLParser::parse(input.get<DeprecatedString>(), &base_url);
// 2. If parsedURL is failure, then throw a TypeError.
if (!parsed_url.is_valid())
@ -416,7 +416,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// 4. If headers is a Headers object, then for each header in its header list, append (headers name, headers value) to thiss headers.
if (auto* header_list = headers.get_pointer<JS::NonnullGCPtr<Infrastructure::HeaderList>>()) {
for (auto& header : *header_list->ptr())
TRY(request_object->headers()->append(String::copy(header.name), String::copy(header.value)));
TRY(request_object->headers()->append(DeprecatedString::copy(header.name), DeprecatedString::copy(header.value)));
}
// 5. Otherwise, fill thiss headers with headers.
else {
@ -449,7 +449,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
// 4. If type is non-null and thiss headerss header list does not contain `Content-Type`, then append (`Content-Type`, type) to thiss headers.
if (type.has_value() && !request_object->headers()->header_list()->contains("Content-Type"sv.bytes()))
TRY(request_object->headers()->append("Content-Type"sv, String::copy(type->span())));
TRY(request_object->headers()->append("Content-Type"sv, DeprecatedString::copy(type->span())));
}
// 37. Let inputOrInitBody be initBody if it is non-null; otherwise inputBody.
@ -492,14 +492,14 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
}
// https://fetch.spec.whatwg.org/#dom-request-method
String Request::method() const
DeprecatedString Request::method() const
{
// The method getter steps are to return thiss requests method.
return String::copy(m_request->method());
return DeprecatedString::copy(m_request->method());
}
// https://fetch.spec.whatwg.org/#dom-request-url
String Request::url() const
DeprecatedString Request::url() const
{
// The url getter steps are to return thiss requests URL, serialized.
return m_request->url().serialize();
@ -520,17 +520,17 @@ Bindings::RequestDestination Request::destination() const
}
// https://fetch.spec.whatwg.org/#dom-request-referrer
String Request::referrer() const
DeprecatedString Request::referrer() const
{
return m_request->referrer().visit(
[&](Infrastructure::Request::Referrer const& referrer) {
switch (referrer) {
// 1. If thiss requests referrer is "no-referrer", then return the empty string.
case Infrastructure::Request::Referrer::NoReferrer:
return String::empty();
return DeprecatedString::empty();
// 2. If thiss requests referrer is "client", then return "about:client".
case Infrastructure::Request::Referrer::Client:
return String { "about:client"sv };
return DeprecatedString { "about:client"sv };
default:
VERIFY_NOT_REACHED();
}
@ -577,7 +577,7 @@ Bindings::RequestRedirect Request::redirect() const
}
// https://fetch.spec.whatwg.org/#dom-request-integrity
String Request::integrity() const
DeprecatedString Request::integrity() const
{
// The integrity getter steps are to return thiss requests integrity metadata.
return m_request->integrity_metadata();

View file

@ -18,20 +18,20 @@
namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#requestinfo
using RequestInfo = Variant<JS::Handle<Request>, String>;
using RequestInfo = Variant<JS::Handle<Request>, DeprecatedString>;
// https://fetch.spec.whatwg.org/#requestinit
struct RequestInit {
Optional<String> method;
Optional<DeprecatedString> method;
Optional<HeadersInit> headers;
Optional<Optional<BodyInit>> body;
Optional<String> referrer;
Optional<DeprecatedString> referrer;
Optional<Bindings::ReferrerPolicy> referrer_policy;
Optional<Bindings::RequestMode> mode;
Optional<Bindings::RequestCredentials> credentials;
Optional<Bindings::RequestCache> cache;
Optional<Bindings::RequestRedirect> redirect;
Optional<String> integrity;
Optional<DeprecatedString> integrity;
Optional<bool> keepalive;
Optional<JS::GCPtr<DOM::AbortSignal>> signal;
Optional<Bindings::RequestDuplex> duplex;
@ -77,17 +77,17 @@ public:
[[nodiscard]] JS::NonnullGCPtr<Infrastructure::Request> request() const { return m_request; }
// JS API functions
[[nodiscard]] String method() const;
[[nodiscard]] String url() const;
[[nodiscard]] DeprecatedString method() const;
[[nodiscard]] DeprecatedString url() const;
[[nodiscard]] JS::NonnullGCPtr<Headers> headers() const;
[[nodiscard]] Bindings::RequestDestination destination() const;
[[nodiscard]] String referrer() const;
[[nodiscard]] DeprecatedString referrer() const;
[[nodiscard]] Bindings::ReferrerPolicy referrer_policy() const;
[[nodiscard]] Bindings::RequestMode mode() const;
[[nodiscard]] Bindings::RequestCredentials credentials() const;
[[nodiscard]] Bindings::RequestCache cache() const;
[[nodiscard]] Bindings::RequestRedirect redirect() const;
[[nodiscard]] String integrity() const;
[[nodiscard]] DeprecatedString integrity() const;
[[nodiscard]] bool keepalive() const;
[[nodiscard]] bool is_reload_navigation() const;
[[nodiscard]] bool is_history_navigation() const;

View file

@ -158,7 +158,7 @@ JS::NonnullGCPtr<Response> Response::error(JS::VM& vm)
}
// https://fetch.spec.whatwg.org/#dom-response-redirect
WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::redirect(JS::VM& vm, String const& url, u16 status)
WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::redirect(JS::VM& vm, DeprecatedString const& url, u16 status)
{
auto& realm = *vm.current_realm();
@ -226,11 +226,11 @@ Bindings::ResponseType Response::type() const
}
// https://fetch.spec.whatwg.org/#dom-response-url
String Response::url() const
DeprecatedString Response::url() const
{
// The url getter steps are to return the empty string if thiss responses URL is null; otherwise thiss responses URL, serialized with exclude fragment set to true.
return !m_response->url().has_value()
? String::empty()
? DeprecatedString::empty()
: m_response->url()->serialize(AK::URL::ExcludeFragment::Yes);
}
@ -256,10 +256,10 @@ bool Response::ok() const
}
// https://fetch.spec.whatwg.org/#dom-response-statustext
String Response::status_text() const
DeprecatedString Response::status_text() const
{
// The statusText getter steps are to return thiss responses status message.
return String::copy(m_response->status_message());
return DeprecatedString::copy(m_response->status_message());
}
// https://fetch.spec.whatwg.org/#dom-response-headers

View file

@ -20,7 +20,7 @@ namespace Web::Fetch {
// https://fetch.spec.whatwg.org/#responseinit
struct ResponseInit {
u16 status;
String status_text;
DeprecatedString status_text;
Optional<HeadersInit> headers;
};
@ -45,14 +45,14 @@ public:
// JS API functions
[[nodiscard]] static JS::NonnullGCPtr<Response> error(JS::VM&);
[[nodiscard]] static WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> redirect(JS::VM&, String const& url, u16 status);
[[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 = {});
[[nodiscard]] Bindings::ResponseType type() const;
[[nodiscard]] String url() const;
[[nodiscard]] DeprecatedString url() const;
[[nodiscard]] bool redirected() const;
[[nodiscard]] u16 status() const;
[[nodiscard]] bool ok() const;
[[nodiscard]] String status_text() const;
[[nodiscard]] DeprecatedString status_text() const;
[[nodiscard]] JS::NonnullGCPtr<Headers> headers() const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone() const;