mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07: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:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
String to_string(HttpRequest::Method method)
|
||||
DeprecatedString to_string(HttpRequest::Method method)
|
||||
{
|
||||
switch (method) {
|
||||
case HttpRequest::Method::GET:
|
||||
|
@ -38,7 +38,7 @@ String to_string(HttpRequest::Method method)
|
|||
}
|
||||
}
|
||||
|
||||
String HttpRequest::method_name() const
|
||||
DeprecatedString HttpRequest::method_name() const
|
||||
{
|
||||
return to_string(m_method);
|
||||
}
|
||||
|
@ -102,15 +102,15 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
|
|||
|
||||
Vector<u8, 256> buffer;
|
||||
|
||||
String method;
|
||||
String resource;
|
||||
String protocol;
|
||||
DeprecatedString method;
|
||||
DeprecatedString resource;
|
||||
DeprecatedString protocol;
|
||||
Vector<Header> headers;
|
||||
Header current_header;
|
||||
ByteBuffer body;
|
||||
|
||||
auto commit_and_advance_to = [&](auto& output, State new_state) {
|
||||
output = String::copy(buffer);
|
||||
output = DeprecatedString::copy(buffer);
|
||||
buffer.clear();
|
||||
state = new_state;
|
||||
};
|
||||
|
@ -228,7 +228,7 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
|
|||
return request;
|
||||
}
|
||||
|
||||
void HttpRequest::set_headers(HashMap<String, String> const& headers)
|
||||
void HttpRequest::set_headers(HashMap<DeprecatedString, DeprecatedString> const& headers)
|
||||
{
|
||||
for (auto& it : headers)
|
||||
m_headers.append({ it.key, it.value });
|
||||
|
@ -249,7 +249,7 @@ Optional<HttpRequest::Header> HttpRequest::get_http_basic_authentication_header(
|
|||
return Header { "Authorization", builder.to_string() };
|
||||
}
|
||||
|
||||
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(String const& value)
|
||||
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(DeprecatedString const& value)
|
||||
{
|
||||
if (!value.starts_with("Basic "sv, AK::CaseSensitivity::CaseInsensitive))
|
||||
return {};
|
||||
|
@ -259,7 +259,7 @@ Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_ba
|
|||
auto decoded_token_bb = decode_base64(token);
|
||||
if (decoded_token_bb.is_error())
|
||||
return {};
|
||||
auto decoded_token = String::copy(decoded_token_bb.value());
|
||||
auto decoded_token = DeprecatedString::copy(decoded_token_bb.value());
|
||||
auto colon_index = decoded_token.find(':');
|
||||
if (!colon_index.has_value())
|
||||
return {};
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Forward.h>
|
||||
|
@ -32,19 +32,19 @@ public:
|
|||
};
|
||||
|
||||
struct Header {
|
||||
String name;
|
||||
String value;
|
||||
DeprecatedString name;
|
||||
DeprecatedString value;
|
||||
};
|
||||
|
||||
struct BasicAuthenticationCredentials {
|
||||
String username;
|
||||
String password;
|
||||
DeprecatedString username;
|
||||
DeprecatedString password;
|
||||
};
|
||||
|
||||
HttpRequest() = default;
|
||||
~HttpRequest() = default;
|
||||
|
||||
String const& resource() const { return m_resource; }
|
||||
DeprecatedString const& resource() const { return m_resource; }
|
||||
Vector<Header> const& headers() const { return m_headers; }
|
||||
|
||||
URL const& url() const { return m_url; }
|
||||
|
@ -56,23 +56,23 @@ public:
|
|||
ByteBuffer const& body() const { return m_body; }
|
||||
void set_body(ByteBuffer&& body) { m_body = move(body); }
|
||||
|
||||
String method_name() const;
|
||||
DeprecatedString method_name() const;
|
||||
ByteBuffer to_raw_request() const;
|
||||
|
||||
void set_headers(HashMap<String, String> const&);
|
||||
void set_headers(HashMap<DeprecatedString, DeprecatedString> const&);
|
||||
|
||||
static Optional<HttpRequest> from_raw_request(ReadonlyBytes);
|
||||
static Optional<Header> get_http_basic_authentication_header(URL const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(String const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(DeprecatedString const&);
|
||||
|
||||
private:
|
||||
URL m_url;
|
||||
String m_resource;
|
||||
DeprecatedString m_resource;
|
||||
Method m_method { GET };
|
||||
Vector<Header> m_headers;
|
||||
ByteBuffer m_body;
|
||||
};
|
||||
|
||||
String to_string(HttpRequest::Method);
|
||||
DeprecatedString to_string(HttpRequest::Method);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
HttpResponse::HttpResponse(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers, size_t size)
|
||||
HttpResponse::HttpResponse(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&& headers, size_t size)
|
||||
: m_code(code)
|
||||
, m_headers(move(headers))
|
||||
, m_downloaded_size(size)
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/NetworkResponse.h>
|
||||
|
||||
namespace HTTP {
|
||||
|
@ -16,7 +16,7 @@ namespace HTTP {
|
|||
class HttpResponse : public Core::NetworkResponse {
|
||||
public:
|
||||
virtual ~HttpResponse() override = default;
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<String, String, CaseInsensitiveStringTraits>&& headers, size_t downloaded_size)
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&& headers, size_t downloaded_size)
|
||||
{
|
||||
return adopt_ref(*new HttpResponse(code, move(headers), downloaded_size));
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ public:
|
|||
int code() const { return m_code; }
|
||||
size_t downloaded_size() const { return m_downloaded_size; }
|
||||
StringView reason_phrase() const { return reason_phrase_for_code(m_code); }
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
|
||||
static StringView reason_phrase_for_code(int code);
|
||||
|
||||
private:
|
||||
HttpResponse(int code, HashMap<String, String, CaseInsensitiveStringTraits>&&, size_t size);
|
||||
HttpResponse(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&&, size_t size);
|
||||
|
||||
int m_code { 0 };
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
||||
size_t m_downloaded_size { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
void HttpsJob::set_certificate(String certificate, String key)
|
||||
void HttpsJob::set_certificate(DeprecatedString certificate, DeprecatedString key)
|
||||
{
|
||||
m_received_client_certificates = TLS::TLSv12::parse_pem_certificate(certificate.bytes(), key.bytes());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
bool received_client_certificates() const { return m_received_client_certificates.has_value(); }
|
||||
Vector<TLS::Certificate> take_client_certificates() const { return m_received_client_certificates.release_value(); }
|
||||
|
||||
void set_certificate(String certificate, String key);
|
||||
void set_certificate(DeprecatedString certificate, DeprecatedString key);
|
||||
|
||||
Function<Vector<TLS::Certificate>()> on_certificate_requested;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
static Optional<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, String const& content_encoding)
|
||||
static Optional<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, DeprecatedString const& content_encoding)
|
||||
{
|
||||
dbgln_if(JOB_DEBUG, "Job::handle_content_encoding: buf has content_encoding={}", content_encoding);
|
||||
|
||||
|
@ -187,11 +187,11 @@ void Job::register_on_ready_to_read(Function<void()> callback)
|
|||
};
|
||||
}
|
||||
|
||||
ErrorOr<String> Job::read_line(size_t size)
|
||||
ErrorOr<DeprecatedString> Job::read_line(size_t size)
|
||||
{
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(size));
|
||||
auto bytes_read = TRY(m_socket->read_until(buffer, "\r\n"sv));
|
||||
return String::copy(bytes_read);
|
||||
return DeprecatedString::copy(bytes_read);
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> Job::receive(size_t size)
|
||||
|
@ -217,7 +217,7 @@ void Job::on_socket_connected()
|
|||
|
||||
if constexpr (JOB_DEBUG) {
|
||||
dbgln("Job: raw_request:");
|
||||
dbgln("{}", String::copy(raw_request));
|
||||
dbgln("{}", DeprecatedString::copy(raw_request));
|
||||
}
|
||||
|
||||
bool success = m_socket->write_or_error(raw_request);
|
||||
|
@ -453,7 +453,7 @@ void Job::on_socket_connected()
|
|||
break;
|
||||
} else {
|
||||
auto chunk = size_lines[0].split_view(';', SplitBehavior::KeepEmpty);
|
||||
String size_string = chunk[0];
|
||||
DeprecatedString size_string = chunk[0];
|
||||
char* endptr;
|
||||
auto size = strtoul(size_string.characters(), &endptr, 16);
|
||||
if (*endptr) {
|
||||
|
|
|
@ -37,7 +37,7 @@ protected:
|
|||
void on_socket_connected();
|
||||
void flush_received_buffers();
|
||||
void register_on_ready_to_read(Function<void()>);
|
||||
ErrorOr<String> read_line(size_t);
|
||||
ErrorOr<DeprecatedString> read_line(size_t);
|
||||
ErrorOr<ByteBuffer> receive(size_t);
|
||||
void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
|
@ -54,8 +54,8 @@ protected:
|
|||
Core::Stream::BufferedSocketBase* m_socket { nullptr };
|
||||
bool m_legacy_connection { false };
|
||||
int m_code { -1 };
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<String> m_set_cookie_headers;
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<DeprecatedString> m_set_cookie_headers;
|
||||
|
||||
struct ReceivedBuffer {
|
||||
ReceivedBuffer(ByteBuffer d)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue