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

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -23,7 +23,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
dbgln_if(REQUESTSERVER_DEBUG, "Request for {} finished", url);
ConnectionKey partial_key { url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default() };
ConnectionKey partial_key { url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default() };
auto fire_off_next_job = [&](auto& cache) {
auto it = find_if(cache.begin(), cache.end(), [&](auto& connection) { return connection.key.hostname == partial_key.hostname && connection.key.port == partial_key.port; });
if (it == cache.end()) {

View file

@ -37,14 +37,14 @@ struct Proxy {
ErrorOr<NonnullOwnPtr<StorageType>> tunnel(URL const& url, Args&&... args)
{
if (data.type == Core::ProxyData::Direct) {
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default(), forward<Args>(args)...));
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default(), forward<Args>(args)...));
}
if (data.type == Core::ProxyData::SOCKS5) {
if constexpr (requires { SocketType::connect(declval<DeprecatedString>(), *proxy_client_storage, forward<Args>(args)...); }) {
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default()));
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), *proxy_client_storage, forward<Args>(args)...));
if constexpr (requires { SocketType::connect(declval<ByteString>(), *proxy_client_storage, forward<Args>(args)...); }) {
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), *proxy_client_storage, forward<Args>(args)...));
} else if constexpr (IsSame<SocketType, Core::TCPSocket>) {
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default()));
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
} else {
return Error::from_string_literal("SOCKS5 not supported for this socket type");
}
@ -101,7 +101,7 @@ struct Connection {
};
struct ConnectionKey {
DeprecatedString hostname;
ByteString hostname;
u16 port { 0 };
Core::ProxyData proxy_data {};
@ -173,7 +173,7 @@ ErrorOr<void> recreate_socket_if_needed(T& connection, URL const& url)
decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job, Core::ProxyData proxy_data = {})
{
using CacheEntryType = RemoveCVReference<decltype(*cache.begin()->value)>;
auto& sockets_for_url = *cache.ensure({ url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default(), proxy_data }, [] { return make<CacheEntryType>(); });
auto& sockets_for_url = *cache.ensure({ url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default(), proxy_data }, [] { return make<CacheEntryType>(); });
Proxy proxy { proxy_data };

View file

@ -30,19 +30,19 @@ void ConnectionFromClient::die()
Core::EventLoop::current().quit(0);
}
Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_supported_protocol(DeprecatedString const& protocol)
Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_supported_protocol(ByteString const& protocol)
{
bool supported = Protocol::find_by_name(protocol.to_lowercase());
return supported;
}
Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_request(DeprecatedString const& method, URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data)
Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_request(ByteString const& method, URL const& url, HashMap<ByteString, ByteString> const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data)
{
if (!url.is_valid()) {
dbgln("StartRequest: Invalid URL requested: '{}'", url);
return { -1, Optional<IPC::File> {} };
}
auto* protocol = Protocol::find_by_name(url.scheme().to_deprecated_string());
auto* protocol = Protocol::find_by_name(url.scheme().to_byte_string());
if (!protocol) {
dbgln("StartRequest: No protocol handler for URL: '{}'", url);
return { -1, Optional<IPC::File> {} };
@ -94,7 +94,7 @@ void ConnectionFromClient::did_request_certificates(Badge<Request>, Request& req
async_certificate_requested(request.id());
}
Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certificate(i32 request_id, DeprecatedString const& certificate, DeprecatedString const& key)
Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certificate(i32 request_id, ByteString const& certificate, ByteString const& key)
{
auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr));
bool success = false;
@ -147,7 +147,7 @@ void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::Ca
}
if (cache_level == CacheLevel::ResolveOnly) {
return Core::deferred_invoke([host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string()] {
return Core::deferred_invoke([host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string()] {
dbgln("EnsureConnection: DNS-preload for {}", host);
(void)gethostbyname(host.characters());
});
@ -156,7 +156,7 @@ void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::Ca
auto& job = Job::ensure(url);
dbgln("EnsureConnection: Pre-connect to {}", url);
auto do_preconnect = [&](auto& cache) {
auto serialized_host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
auto serialized_host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string();
auto it = cache.find({ serialized_host, url.port_or_default() });
if (it == cache.end() || it->value->is_empty())
ConnectionCache::get_or_create_connection(cache, url, job);

View file

@ -31,10 +31,10 @@ public:
private:
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(DeprecatedString const&) override;
virtual Messages::RequestServer::StartRequestResponse start_request(DeprecatedString const&, URL const&, HashMap<DeprecatedString, DeprecatedString> const&, ByteBuffer const&, Core::ProxyData const&) override;
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(ByteString const&) override;
virtual Messages::RequestServer::StartRequestResponse start_request(ByteString const&, URL const&, HashMap<ByteString, ByteString> const&, ByteBuffer const&, Core::ProxyData const&) override;
virtual Messages::RequestServer::StopRequestResponse stop_request(i32) override;
virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, DeprecatedString const&, DeprecatedString const&) override;
virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, ByteString const&, ByteString const&) override;
virtual void ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) override;
HashMap<i32, OwnPtr<Request>> m_requests;

View file

@ -17,7 +17,7 @@ GeminiProtocol::GeminiProtocol()
{
}
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, DeprecatedString const&, const URL& url, HashMap<DeprecatedString, DeprecatedString> const&, ReadonlyBytes, Core::ProxyData proxy_data)
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, ByteString const&, const URL& url, HashMap<ByteString, ByteString> const&, ReadonlyBytes, Core::ProxyData proxy_data)
{
Gemini::GeminiRequest request;
request.set_url(url);

View file

@ -15,7 +15,7 @@ public:
GeminiProtocol();
virtual ~GeminiProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
};
}

View file

@ -23,7 +23,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
if (auto* response = m_job->response()) {
set_downloaded_size(MUST(m_job->response_length()));
if (!response->meta().is_empty()) {
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> headers;
headers.set("meta", response->meta());
// Note: We're setting content-type to meta only on status==SUCCESS
// we should perhaps have a better mechanism for this, since we
@ -46,7 +46,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
};
}
void GeminiRequest::set_certificate(DeprecatedString, DeprecatedString)
void GeminiRequest::set_certificate(ByteString, ByteString)
{
}

View file

@ -25,7 +25,7 @@ public:
private:
explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::File>&&);
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
virtual void set_certificate(ByteString certificate, ByteString key) override;
NonnullRefPtr<Gemini::Job> m_job;
};

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/Optional.h>
@ -61,7 +61,7 @@ void init(TSelf* self, TJob job)
}
template<typename TBadgedProtocol, typename TPipeResult>
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {})
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {})
{
using TJob = typename TBadgedProtocol::Type::JobType;
using TRequest = typename TBadgedProtocol::Type::RequestType;

View file

@ -6,7 +6,7 @@
#include <AK/Badge.h>
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/URL.h>
@ -22,7 +22,7 @@ HttpProtocol::HttpProtocol()
{
}
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
{
return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request(), proxy_data);
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/URL.h>
@ -27,7 +27,7 @@ public:
HttpProtocol();
~HttpProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
};
}

View file

@ -6,7 +6,7 @@
#include <AK/Badge.h>
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/URL.h>
@ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol()
{
}
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
{
return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request(), proxy_data);
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/URL.h>
@ -27,7 +27,7 @@ public:
HttpsProtocol();
~HttpsProtocol() override = default;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
};
}

View file

@ -18,7 +18,7 @@ HttpsRequest::HttpsRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::Htt
Detail::init(this, job);
}
void HttpsRequest::set_certificate(DeprecatedString certificate, DeprecatedString key)
void HttpsRequest::set_certificate(ByteString certificate, ByteString key)
{
m_job->set_certificate(move(certificate), move(key));
}

View file

@ -26,7 +26,7 @@ public:
private:
explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::File>&&);
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
virtual void set_certificate(ByteString certificate, ByteString key) override;
NonnullRefPtr<HTTP::HttpsJob> m_job;
};

View file

@ -13,18 +13,18 @@
namespace RequestServer {
static HashMap<DeprecatedString, Protocol*>& all_protocols()
static HashMap<ByteString, Protocol*>& all_protocols()
{
static HashMap<DeprecatedString, Protocol*> map;
static HashMap<ByteString, Protocol*> map;
return map;
}
Protocol* Protocol::find_by_name(DeprecatedString const& name)
Protocol* Protocol::find_by_name(ByteString const& name)
{
return all_protocols().get(name).value_or(nullptr);
}
Protocol::Protocol(DeprecatedString const& name)
Protocol::Protocol(ByteString const& name)
{
all_protocols().set(name, this);
}

View file

@ -17,13 +17,13 @@ class Protocol {
public:
virtual ~Protocol();
DeprecatedString const& name() const { return m_name; }
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0;
ByteString const& name() const { return m_name; }
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0;
static Protocol* find_by_name(DeprecatedString const&);
static Protocol* find_by_name(ByteString const&);
protected:
explicit Protocol(DeprecatedString const& name);
explicit Protocol(ByteString const& name);
struct Pipe {
int read_fd { -1 };
int write_fd { -1 };
@ -31,7 +31,7 @@ protected:
static ErrorOr<Pipe> get_pipe_for_request();
private:
DeprecatedString m_name;
ByteString m_name;
};
}

View file

@ -24,13 +24,13 @@ void Request::stop()
m_client.did_finish_request({}, *this, false);
}
void Request::set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers)
void Request::set_response_headers(HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers)
{
m_response_headers = response_headers;
m_client.did_receive_headers({}, *this);
}
void Request::set_certificate(DeprecatedString, DeprecatedString)
void Request::set_certificate(ByteString, ByteString)
{
}

View file

@ -25,10 +25,10 @@ public:
Optional<u32> status_code() const { return m_status_code; }
Optional<u64> total_size() const { return m_total_size; }
size_t downloaded_size() const { return m_downloaded_size; }
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
void stop();
virtual void set_certificate(DeprecatedString, DeprecatedString);
virtual void set_certificate(ByteString, ByteString);
// FIXME: Want Badge<Protocol>, but can't make one from HttpProtocol, etc.
void set_request_fd(int fd) { m_request_fd = fd; }
@ -38,7 +38,7 @@ public:
void did_progress(Optional<u64> total_size, u64 downloaded_size);
void set_status_code(u32 status_code) { m_status_code = status_code; }
void did_request_certificates();
void set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const&);
void set_response_headers(HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const&);
void set_downloaded_size(size_t size) { m_downloaded_size = size; }
Core::File const& output_stream() const { return *m_output_stream; }
@ -53,7 +53,7 @@ private:
Optional<u64> m_total_size {};
size_t m_downloaded_size { 0 };
NonnullOwnPtr<Core::File> m_output_stream;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> m_response_headers;
};
}

View file

@ -4,7 +4,7 @@ endpoint RequestClient
{
request_progress(i32 request_id, Optional<u64> total_size, u64 downloaded_size) =|
request_finished(i32 request_id, bool success, u64 total_size) =|
headers_became_available(i32 request_id, HashMap<DeprecatedString,DeprecatedString,CaseInsensitiveStringTraits> response_headers, Optional<u32> status_code) =|
headers_became_available(i32 request_id, HashMap<ByteString,ByteString,CaseInsensitiveStringTraits> response_headers, Optional<u32> status_code) =|
// Certificate requests
certificate_requested(i32 request_id) =|

View file

@ -4,11 +4,11 @@
endpoint RequestServer
{
// Test if a specific protocol is supported, e.g "http"
is_supported_protocol(DeprecatedString protocol) => (bool supported)
is_supported_protocol(ByteString protocol) => (bool supported)
start_request(DeprecatedString method, URL url, HashMap<DeprecatedString,DeprecatedString> request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) => (i32 request_id, Optional<IPC::File> response_fd)
start_request(ByteString method, URL url, HashMap<ByteString,ByteString> request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) => (i32 request_id, Optional<IPC::File> response_fd)
stop_request(i32 request_id) => (bool success)
set_certificate(i32 request_id, DeprecatedString certificate, DeprecatedString key) => (bool success)
set_certificate(i32 request_id, ByteString certificate, ByteString key) => (bool success)
ensure_connection(URL url, ::RequestServer::CacheLevel cache_level) =|
}