1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:17:35 +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

@ -81,7 +81,7 @@ void Client::start()
}
auto request = builder.to_byte_buffer();
dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", String::copy(request));
dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", DeprecatedString::copy(request));
auto maybe_did_handle = handle_request(request);
if (maybe_did_handle.is_error()) {
@ -233,9 +233,9 @@ ErrorOr<void> Client::send_redirect(StringView redirect_path, HTTP::HttpRequest
return {};
}
static String folder_image_data()
static DeprecatedString folder_image_data()
{
static String cache;
static DeprecatedString cache;
if (cache.is_empty()) {
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors();
cache = encode_base64(file->bytes());
@ -243,9 +243,9 @@ static String folder_image_data()
return cache;
}
static String file_image_data()
static DeprecatedString file_image_data()
{
static String cache;
static DeprecatedString cache;
if (cache.is_empty()) {
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors();
cache = encode_base64(file->bytes());
@ -253,7 +253,7 @@ static String file_image_data()
return cache;
}
ErrorOr<void> Client::handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const& request)
ErrorOr<void> Client::handle_directory_listing(DeprecatedString const& requested_path, DeprecatedString const& real_path, HTTP::HttpRequest const& request)
{
StringBuilder builder;
@ -277,7 +277,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
builder.append("<code><table>\n"sv);
Core::DirIterator dt(real_path);
Vector<String> names;
Vector<DeprecatedString> names;
while (dt.has_next())
names.append(dt.next_path());
quick_sort(names);
@ -332,7 +332,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
return send_response(stream, request, { .type = "text/html", .length = response.length() });
}
ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const& request, Vector<String> const& headers)
ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const& request, Vector<DeprecatedString> const& headers)
{
auto reason_phrase = HTTP::HttpResponse::reason_phrase_for_code(code);

View file

@ -23,17 +23,17 @@ private:
Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket>, Core::Object* parent);
struct ContentInfo {
String type;
DeprecatedString type;
size_t length {};
};
ErrorOr<bool> handle_request(ReadonlyBytes);
ErrorOr<void> send_response(InputStream&, HTTP::HttpRequest const&, ContentInfo);
ErrorOr<void> send_redirect(StringView redirect, HTTP::HttpRequest const&);
ErrorOr<void> send_error_response(unsigned code, HTTP::HttpRequest const&, Vector<String> const& headers = {});
ErrorOr<void> send_error_response(unsigned code, HTTP::HttpRequest const&, Vector<DeprecatedString> const& headers = {});
void die();
void log_response(unsigned code, HTTP::HttpRequest const&);
ErrorOr<void> handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const&);
ErrorOr<void> handle_directory_listing(DeprecatedString const& requested_path, DeprecatedString const& real_path, HTTP::HttpRequest const&);
bool verify_credentials(Vector<HTTP::HttpRequest::Header> const&);
NonnullOwnPtr<Core::Stream::BufferedTCPSocket> m_socket;

View file

@ -10,7 +10,7 @@ namespace WebServer {
static Configuration* s_configuration = nullptr;
Configuration::Configuration(String root_path)
Configuration::Configuration(DeprecatedString root_path)
: m_root_path(move(root_path))
{
VERIFY(!s_configuration);

View file

@ -6,26 +6,26 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <LibHTTP/HttpRequest.h>
namespace WebServer {
class Configuration {
public:
Configuration(String root_path);
Configuration(DeprecatedString root_path);
String const& root_path() const { return m_root_path; }
DeprecatedString const& root_path() const { return m_root_path; }
Optional<HTTP::HttpRequest::BasicAuthenticationCredentials> const& credentials() const { return m_credentials; }
void set_root_path(String root_path) { m_root_path = move(root_path); }
void set_root_path(DeprecatedString root_path) { m_root_path = move(root_path); }
void set_credentials(Optional<HTTP::HttpRequest::BasicAuthenticationCredentials> credentials) { m_credentials = move(credentials); }
static Configuration const& the();
private:
String m_root_path;
DeprecatedString m_root_path;
Optional<HTTP::HttpRequest::BasicAuthenticationCredentials> m_credentials;
};

View file

@ -20,14 +20,14 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
String default_listen_address = "0.0.0.0";
DeprecatedString default_listen_address = "0.0.0.0";
u16 default_port = 8000;
String root_path = "/www";
DeprecatedString root_path = "/www";
String listen_address = default_listen_address;
DeprecatedString listen_address = default_listen_address;
int port = default_port;
String username;
String password;
DeprecatedString username;
DeprecatedString password;
Core::ArgsParser args_parser;
args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");