diff --git a/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Libraries/LibWeb/Fetch/FetchMethod.cpp index 7a95e4d45f2..c0124482eab 100644 --- a/Libraries/LibWeb/Fetch/FetchMethod.cpp +++ b/Libraries/LibWeb/Fetch/FetchMethod.cpp @@ -104,7 +104,7 @@ GC::Ref fetch(JS::VM& vm, RequestInfo const& input, RequestInit // 3. If response is a network error, then reject p with a TypeError and abort these steps. if (response->is_network_error()) { - auto message = response->network_error_message().value_or("Response is a network error"sv); + auto message = response->network_error_message().value_or("Response is a network error"_string); WebIDL::reject_promise(relevant_realm, promise_capability, JS::TypeError::create(relevant_realm, message)); return; } diff --git a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp index bdf51051c2d..08c7d0f85d3 100644 --- a/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp +++ b/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp @@ -284,7 +284,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra // 3. If request’s local-URLs-only flag is set and request’s current URL is not local, then set response to a // network error. if (request->local_urls_only() && !Infrastructure::is_local_url(request->current_url())) - response = Infrastructure::Response::network_error(vm, "Request with 'local-URLs-only' flag must have a local URL"sv); + response = Infrastructure::Response::network_error(vm, "Request with 'local-URLs-only' flag must have a local URL"_string); // 4. Run report Content Security Policy violations for request. ContentSecurityPolicy::report_content_security_policy_violations_for_request(realm, request); @@ -299,7 +299,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra if (Infrastructure::block_bad_port(request) == Infrastructure::RequestOrResponseBlocking::Blocked || MixedContent::should_fetching_request_be_blocked_as_mixed_content(request) == Infrastructure::RequestOrResponseBlocking::Blocked || ContentSecurityPolicy::should_request_be_blocked_by_content_security_policy(realm, request) == ContentSecurityPolicy::Directives::Directive::Result::Blocked) { - response = Infrastructure::Response::network_error(vm, "Request was blocked"sv); + response = Infrastructure::Response::network_error(vm, "Request was blocked"_string); } // 8. If request’s referrer policy is the empty string, then set request’s referrer policy to request’s policy @@ -374,13 +374,13 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra // -> request’s mode is "same-origin" else if (request->mode() == Infrastructure::Request::Mode::SameOrigin) { // Return a network error. - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'same-origin' mode must have same URL and request origin"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'same-origin' mode must have same URL and request origin"_string)); } // -> request’s mode is "no-cors" else if (request->mode() == Infrastructure::Request::Mode::NoCORS) { // 1. If request’s redirect mode is not "follow", then return a network error. if (request->redirect_mode() != Infrastructure::Request::RedirectMode::Follow) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'no-cors' mode must have redirect mode set to 'follow'"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'no-cors' mode must have redirect mode set to 'follow'"_string)); // 2. Set request’s response tainting to "opaque". request->set_response_tainting(Infrastructure::Request::ResponseTainting::Opaque); @@ -394,7 +394,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra VERIFY(request->mode() == Infrastructure::Request::Mode::CORS); // Return a network error. - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode must have URL with HTTP or HTTPS scheme"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode must have URL with HTTP or HTTPS scheme"_string)); } // -> request’s use-CORS-preflight flag is set // -> request’s unsafe-request flag is set and either request’s method is not a CORS-safelisted method or @@ -563,7 +563,7 @@ WebIDL::ExceptionOr> main_fetch(JS::Realm& realm, Infra // 1. Let processBodyError be this step: run fetch response handover given fetchParams and a network // error. auto process_body_error = GC::create_function(vm.heap(), [&realm, &vm, &fetch_params](JS::Value) { - fetch_response_handover(realm, fetch_params, Infrastructure::Response::network_error(vm, "Response body could not be processed"sv)); + fetch_response_handover(realm, fetch_params, Infrastructure::Response::network_error(vm, "Response body could not be processed"_string)); }); // 2. If response’s body is null, then run processBodyError and abort these steps. @@ -842,7 +842,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf if (request->method() != "GET"sv.bytes() || !blob_url_entry.has_value()) { // FIXME: Handle "blobURLEntry’s object is not a Blob object". It could be a MediaSource object, but we // have not yet implemented the Media Source Extensions spec. - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has an invalid 'blob:' URL"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has an invalid 'blob:' URL"_string)); } // 3. Let requestEnvironment be the result of determining the environment given request. @@ -853,7 +853,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf // 5. If isTopLevelNavigation is false and requestEnvironment is null, then return a network error. if (!is_top_level_navigation && !request_environment) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request is missing fetch client"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request is missing fetch client"_string)); // 6. Let navigationOrEnvironment be the string "navigation" if isTopLevelNavigation is true; otherwise, requestEnvironment. auto navigation_or_environment = [&]() -> Variant> { @@ -868,7 +868,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf // 8. If blob is not a Blob object, then return a network error. // FIXME: This should probably check for a MediaSource object as well, once we implement that. if (!blob_object.has_value()) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to obtain a Blob object from 'blob:' URL"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to obtain a Blob object from 'blob:' URL"_string)); auto const blob = FileAPI::Blob::create(realm, blob_object->data, blob_object->type); // 9. Let response be a new response. @@ -914,7 +914,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf // 4. If rangeValue is failure, then return a network error. if (!maybe_range_value.has_value()) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to parse single range header value"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to parse single range header value"_string)); // 5. Let (rangeStart, rangeEnd) be rangeValue. auto& [range_start, range_end] = maybe_range_value.value(); @@ -933,7 +933,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf else { // 1. If rangeStart is greater than or equal to fullLength, then return a network error. if (*range_start >= full_length) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "rangeStart is greater than or equal to fullLength"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "rangeStart is greater than or equal to fullLength"_string)); // 2. If rangeEnd is null or rangeEnd is greater than or equal to fullLength, then set rangeEnd to fullLength − 1. if (!range_end.has_value() || *range_end >= full_length) @@ -986,7 +986,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf // 2. If dataURLStruct is failure, then return a network error. if (data_url_struct.is_error()) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to process 'data:' URL"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Failed to process 'data:' URL"_string)); // 3. Let mimeType be dataURLStruct’s MIME type, serialized. auto const& mime_type = data_url_struct.value().mime_type.serialized(); @@ -1010,7 +1010,7 @@ WebIDL::ExceptionOr> scheme_fetch(JS::Realm& realm, Inf if (request->origin().has() && (request->origin().get().is_opaque() || request->origin().get().scheme() == "file"sv || request->origin().get().scheme() == "resource"sv)) return TRY(nonstandard_resource_loader_file_or_http_network_fetch(realm, fetch_params)); else - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'file:' or 'resource:' URL blocked"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'file:' or 'resource:' URL blocked"_string)); } // -> HTTP(S) scheme else if (Infrastructure::is_http_or_https_scheme(request->current_url().scheme())) { @@ -1090,7 +1090,7 @@ WebIDL::ExceptionOr> http_fetch(JS::Realm& realm, Infra // - request’s redirect mode is not "follow" and response’s URL list has more than one item. || (request->redirect_mode() != Infrastructure::Request::RedirectMode::Follow && response->url_list().size() > 1)) { // then return a network error. - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Invalid request/response state combination"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Invalid request/response state combination"_string)); } } } @@ -1269,17 +1269,17 @@ WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm& rea // 5. If locationURL is failure, then return a network error. if (location_url_or_error.is_error()) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request redirect URL is invalid"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request redirect URL is invalid"_string)); auto location_url = location_url_or_error.release_value().release_value(); // 6. If locationURL’s scheme is not an HTTP(S) scheme, then return a network error. if (!Infrastructure::is_http_or_https_scheme(location_url.scheme())) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request redirect URL must have HTTP or HTTPS scheme"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request redirect URL must have HTTP or HTTPS scheme"_string)); // 7. If request’s redirect count is 20, then return a network error. if (request->redirect_count() == 20) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has reached maximum redirect count of 20"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has reached maximum redirect count of 20"_string)); // 8. Increase request’s redirect count by 1. request->set_redirect_count(request->redirect_count() + 1); @@ -1290,20 +1290,20 @@ WebIDL::ExceptionOr> http_redirect_fetch(JS::Realm& rea && location_url.includes_credentials() && request->origin().has() && !request->origin().get().is_same_origin(location_url.origin())) { - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode and different URL and request origin must not include credentials in redirect URL"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' mode and different URL and request origin must not include credentials in redirect URL"_string)); } // 10. If request’s response tainting is "cors" and locationURL includes credentials, then return a network error. // NOTE: This catches a cross-origin resource redirecting to a same-origin URL. if (request->response_tainting() == Infrastructure::Request::ResponseTainting::CORS && location_url.includes_credentials()) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' response tainting must not include credentials in redirect URL"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'cors' response tainting must not include credentials in redirect URL"_string)); // 11. If internalResponse’s status is not 303, request’s body is non-null, and request’s body’s source is null, then // return a network error. if (internal_response->status() != 303 && !request->body().has() && request->body().get>()->source().has()) { - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has body but no body source"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request has body but no body source"_string)); } // 12. If one of the following is true @@ -1811,7 +1811,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re // 5. If the sum of contentLength and inflightKeepaliveBytes is greater than 64 kibibytes, then return a network error. if ((content_length.value() + inflight_keep_alive_bytes) > keepalive_maximum_size) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Keepalive request exceeded maximum allowed size of 64 KiB"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Keepalive request exceeded maximum allowed size of 64 KiB"_string)); // NOTE: The above limit ensures that requests that are allowed to outlive the environment settings object // and contain a body, have a bounded size and are not allowed to stay alive indefinitely. @@ -2053,7 +2053,7 @@ WebIDL::ExceptionOr> http_network_or_cache_fetch(JS::Re if (!response) { // 1. If httpRequest’s cache mode is "only-if-cached", then return a network error. if (http_request->cache_mode() == Infrastructure::Request::CacheMode::OnlyIfCached) - return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'only-if-cached' cache mode doesn't have a cached response"sv)); + return PendingResponse::create(vm, request, Infrastructure::Response::network_error(vm, "Request with 'only-if-cached' cache mode doesn't have a cached response"_string)); // 2. Let forwardResponse be the result of running HTTP-network fetch given httpFetchParams, includeCredentials, // and isNewConnectionFetch. @@ -2598,7 +2598,7 @@ WebIDL::ExceptionOr> cors_preflight_fetch(JS::Realm& re // is "include" or methods does not contain `*`, then return a network error. if (!methods.contains_slow(request.method()) && !Infrastructure::is_cors_safelisted_method(request.method())) { if (request.credentials_mode() == Infrastructure::Request::CredentialsMode::Include) { - returned_pending_response->resolve(Infrastructure::Response::network_error(vm, TRY_OR_IGNORE(String::formatted("Non-CORS-safelisted method '{}' not found in the CORS-preflight response's Access-Control-Allow-Methods header (the header may be missing). '*' is not allowed as the main request includes credentials."sv, StringView { request.method() })))); + returned_pending_response->resolve(Infrastructure::Response::network_error(vm, TRY_OR_IGNORE(String::formatted("Non-CORS-safelisted method '{}' not found in the CORS-preflight response's Access-Control-Allow-Methods header (the header may be missing). '*' is not allowed as the main request includes credentials."_string, StringView { request.method() })))); return; } diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index 6686b9512d1..959759e12be 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -47,14 +47,14 @@ GC::Ref Response::create(JS::VM& vm) GC::Ref Response::aborted_network_error(JS::VM& vm) { - auto response = network_error(vm, "Fetch has been aborted"sv); + auto response = network_error(vm, "Fetch has been aborted"_string); response->set_aborted(true); return response; } -GC::Ref Response::network_error(JS::VM& vm, Variant message) +GC::Ref Response::network_error(JS::VM& vm, String message) { - dbgln_if(WEB_FETCH_DEBUG, "Fetch: Creating network error response with message: {}", message.visit([](auto const& s) -> StringView { return s; })); + dbgln_if(WEB_FETCH_DEBUG, "Fetch: Creating network error response with message: {}", message); auto response = Response::create(vm); response->set_status(0); response->set_type(Type::Error); @@ -72,7 +72,7 @@ GC::Ref Response::appropriate_network_error(JS::VM& vm, FetchParams co // 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); + : network_error(vm, "Fetch has been terminated"_string); } // https://fetch.spec.whatwg.org/#concept-aborted-network-error @@ -341,12 +341,6 @@ u64 Response::stale_while_revalidate_lifetime() const } // Non-standard -Optional Response::network_error_message() const -{ - if (!m_network_error_message.has_value()) - return {}; - return m_network_error_message->visit([](auto const& s) -> StringView { return s; }); -} FilteredResponse::FilteredResponse(GC::Ref internal_response, GC::Ref header_list) : Response(header_list) diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h index 7137a159e13..d924ae059ad 100644 --- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h +++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h @@ -58,7 +58,7 @@ public: [[nodiscard]] static GC::Ref create(JS::VM&); [[nodiscard]] static GC::Ref aborted_network_error(JS::VM&); - [[nodiscard]] static GC::Ref network_error(JS::VM&, Variant message); + [[nodiscard]] static GC::Ref network_error(JS::VM&, String message); [[nodiscard]] static GC::Ref appropriate_network_error(JS::VM&, FetchParams const&); virtual ~Response() = default; @@ -124,7 +124,7 @@ public: [[nodiscard]] bool is_stale() const; // Non-standard - [[nodiscard]] Optional network_error_message() const; + [[nodiscard]] Optional const& network_error_message() const { return m_network_error_message; } MonotonicTime response_time() const { return m_response_time; } protected: @@ -201,7 +201,7 @@ private: ByteBuffer m_method; MonotonicTime m_response_time; - Optional> m_network_error_message; + Optional m_network_error_message; public: [[nodiscard]] ByteBuffer const& method() const { return m_method; } diff --git a/Libraries/LibWeb/Fetch/Response.cpp b/Libraries/LibWeb/Fetch/Response.cpp index 731d388f5fc..48b2af45d76 100644 --- a/Libraries/LibWeb/Fetch/Response.cpp +++ b/Libraries/LibWeb/Fetch/Response.cpp @@ -173,7 +173,7 @@ GC::Ref Response::error(JS::VM& vm) { // The static error() method steps are to return the result of creating a Response object, given a new network error, "immutable", and this’s relevant Realm. // FIXME: How can we reliably get 'this', i.e. the object the function was called on, in IDL-defined functions? - return Response::create(*vm.current_realm(), Infrastructure::Response::network_error(vm, "Response created via `Response.error()`"sv), Headers::Guard::Immutable); + return Response::create(*vm.current_realm(), Infrastructure::Response::network_error(vm, "Response created via `Response.error()`"_string), Headers::Guard::Immutable); } // https://fetch.spec.whatwg.org/#dom-response-redirect diff --git a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 43014e384d9..249e6a0fa4c 100644 --- a/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -1032,8 +1032,8 @@ WebIDL::ExceptionOr HTMLMediaElement::fetch_resource(URL::URL const& url_r // 4. If the result of verifying response given the current media resource and byteRange is false, then abort these steps. // NOTE: We do this step before creating the updateMedia task so that we can invoke the failure callback. if (!verify_response(response, byte_range)) { - auto error_message = response->network_error_message().value_or("Failed to fetch media resource"sv); - failure_callback(String::from_utf8(error_message).release_value_but_fixme_should_propagate_errors()); + auto error_message = response->network_error_message().value_or("Failed to fetch media resource"_string); + failure_callback(error_message); return; } diff --git a/Libraries/LibWeb/HTML/Navigable.cpp b/Libraries/LibWeb/HTML/Navigable.cpp index 3a5f1ba62b8..40db75751c8 100644 --- a/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Libraries/LibWeb/HTML/Navigable.cpp @@ -980,7 +980,7 @@ static WebIDL::ExceptionOr create_navigation // 3. If the result of should navigation request of type be blocked by Content Security Policy? given request and cspNavigationType is "Blocked", then set response to a network error and break. [CSP] if (ContentSecurityPolicy::should_navigation_request_of_type_be_blocked_by_content_security_policy(request, csp_navigation_type) == ContentSecurityPolicy::Directives::Directive::Result::Blocked) { - response_holder->set_response(Fetch::Infrastructure::Response::network_error(vm, "Blocked by Content Security Policy"sv)); + response_holder->set_response(Fetch::Infrastructure::Response::network_error(vm, "Blocked by Content Security Policy"_string)); break; } @@ -1144,7 +1144,7 @@ static WebIDL::ExceptionOr create_navigation // then return null. if (response_holder->response()->is_network_error()) { // AD-HOC: We pass the error message if we have one in NullWithError - if (response_holder->response()->network_error_message().has_value() && !response_holder->response()->network_error_message().value().is_null()) + if (response_holder->response()->network_error_message().has_value()) return response_holder->response()->network_error_message().value(); else return Navigable::NullOrError {}; @@ -1312,7 +1312,7 @@ WebIDL::ExceptionOr Navigable::populate_session_history_entry_document( }, [](GC::Ref) { return false; })) { // 1. Set entry's document state's document to the result of creating a document for inline content that doesn't have a DOM, given navigable, null, navTimingType, and userInvolvement. The inline content should indicate to the user the sort of error that occurred. - auto error_message = navigation_params.has() ? navigation_params.get().value_or("Unknown error"sv) : "The request was denied."sv; + auto error_message = navigation_params.has() ? navigation_params.get().value_or("Unknown error"_string) : "The request was denied."_string; auto error_html = load_error_page(entry->url(), error_message).release_value_but_fixme_should_propagate_errors(); entry->document_state()->set_document(create_document_for_inline_content(this, navigation_id, user_involvement, [this, error_html](auto& document) { diff --git a/Libraries/LibWeb/HTML/Navigable.h b/Libraries/LibWeb/HTML/Navigable.h index 8b0f3630b60..4a3830422fe 100644 --- a/Libraries/LibWeb/HTML/Navigable.h +++ b/Libraries/LibWeb/HTML/Navigable.h @@ -42,7 +42,7 @@ class Navigable : public JS::Cell public: virtual ~Navigable() override; - using NullOrError = Optional; + using NullOrError = Optional; using NavigationParamsVariant = Variant, GC::Ref>; ErrorOr initialize_navigable(GC::Ref document_state, GC::Ptr parent); diff --git a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index fa63675eed4..8fb44c1cfc3 100644 --- a/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -63,7 +63,7 @@ WebIDL::ExceptionOr> XMLHttpRequest::construct_impl(JS:: { auto upload_object = realm.create(realm); auto author_request_headers = Fetch::Infrastructure::HeaderList::create(realm.vm()); - auto response = Fetch::Infrastructure::Response::network_error(realm.vm(), "Not sent yet"sv); + auto response = Fetch::Infrastructure::Response::network_error(realm.vm(), "Not sent yet"_string); auto fetch_controller = Fetch::Infrastructure::FetchController::create(realm.vm()); return realm.create(realm, *upload_object, *author_request_headers, *response, *fetch_controller); } @@ -529,7 +529,7 @@ WebIDL::ExceptionOr XMLHttpRequest::open(String const& method_string, Stri // Empty this’s author request headers. m_author_request_headers->clear(); // Set this’s response to a network error. - m_response = Fetch::Infrastructure::Response::network_error(realm().vm(), "Not yet sent"sv); + m_response = Fetch::Infrastructure::Response::network_error(realm().vm(), "Not yet sent"_string); // Set this’s received bytes to the empty byte sequence. m_received_bytes = {}; // Set this’s response object to null. @@ -845,7 +845,7 @@ WebIDL::ExceptionOr XMLHttpRequest::send(Optionalvm(); // 1. Set this’s response to a network error. - m_response = Fetch::Infrastructure::Response::network_error(vm, "A network error occurred processing body."sv); + m_response = Fetch::Infrastructure::Response::network_error(vm, "A network error occurred processing body."_string); // 2. Run handle errors for this. // NOTE: This cannot throw, as `handle_errors` only throws in a synchronous context. // FIXME: However, we can receive allocation failures, but we can't propagate them anywhere currently. @@ -1140,7 +1140,7 @@ void XMLHttpRequest::abort() // Spec Note: No readystatechange event is dispatched. if (m_state == State::Done) { m_state = State::Unsent; - m_response = Fetch::Infrastructure::Response::network_error(vm(), "Not yet sent"sv); + m_response = Fetch::Infrastructure::Response::network_error(vm(), "Not yet sent"_string); } } @@ -1245,7 +1245,7 @@ JS::ThrowCompletionOr XMLHttpRequest::request_error_steps(FlyString const& m_send = false; // 3. Set xhr’s response to a network error. - m_response = Fetch::Infrastructure::Response::network_error(realm().vm(), "Failed to load"sv); + m_response = Fetch::Infrastructure::Response::network_error(realm().vm(), "Failed to load"_string); // 4. If xhr’s synchronous flag is set, then throw exception. if (m_synchronous) { diff --git a/Services/WebWorker/DedicatedWorkerHost.cpp b/Services/WebWorker/DedicatedWorkerHost.cpp index 9ebabc5430d..423b11353cf 100644 --- a/Services/WebWorker/DedicatedWorkerHost.cpp +++ b/Services/WebWorker/DedicatedWorkerHost.cpp @@ -124,7 +124,7 @@ void DedicatedWorkerHost::run(GC::Ref page, Web::HTML::TransferDataHo // 3. If the Run CSP initialization for a global object algorithm returns "Blocked" when executed upon worker // global scope, set response to a network error. [CSP] if (worker_global_scope->run_csp_initialization() == Web::ContentSecurityPolicy::Directives::Directive::Result::Blocked) { - response = Web::Fetch::Infrastructure::Response::network_error(vm, "Blocked by Content Security Policy"sv); + response = Web::Fetch::Infrastructure::Response::network_error(vm, "Blocked by Content Security Policy"_string); } // FIXME: 4. If worker global scope's embedder policy's value is compatible with cross-origin isolation and is shared is true,