mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:37:46 +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:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -115,15 +115,15 @@ ErrorOr<HttpRequest, HttpRequest::ParseError> HttpRequest::from_raw_request(Read
|
|||
Vector<u8, 256> buffer;
|
||||
|
||||
Optional<unsigned> content_length;
|
||||
DeprecatedString method;
|
||||
DeprecatedString resource;
|
||||
DeprecatedString protocol;
|
||||
ByteString method;
|
||||
ByteString resource;
|
||||
ByteString protocol;
|
||||
Vector<Header> headers;
|
||||
Header current_header;
|
||||
ByteBuffer body;
|
||||
|
||||
auto commit_and_advance_to = [&](auto& output, State new_state) {
|
||||
output = DeprecatedString::copy(buffer);
|
||||
output = ByteString::copy(buffer);
|
||||
buffer.clear();
|
||||
state = new_state;
|
||||
};
|
||||
|
@ -237,8 +237,8 @@ ErrorOr<HttpRequest, HttpRequest::ParseError> HttpRequest::from_raw_request(Read
|
|||
request.m_headers = move(headers);
|
||||
auto url_parts = resource.split_limit('?', 2, SplitBehavior::KeepEmpty);
|
||||
|
||||
auto url_part_to_string = [](DeprecatedString const& url_part) -> ErrorOr<String, ParseError> {
|
||||
auto query_string_or_error = String::from_deprecated_string(url_part);
|
||||
auto url_part_to_string = [](ByteString const& url_part) -> ErrorOr<String, ParseError> {
|
||||
auto query_string_or_error = String::from_byte_string(url_part);
|
||||
if (!query_string_or_error.is_error())
|
||||
return query_string_or_error.release_value();
|
||||
|
||||
|
@ -263,7 +263,7 @@ ErrorOr<HttpRequest, HttpRequest::ParseError> HttpRequest::from_raw_request(Read
|
|||
return request;
|
||||
}
|
||||
|
||||
void HttpRequest::set_headers(HashMap<DeprecatedString, DeprecatedString> const& headers)
|
||||
void HttpRequest::set_headers(HashMap<ByteString, ByteString> const& headers)
|
||||
{
|
||||
for (auto& it : headers)
|
||||
m_headers.append({ it.key, it.value });
|
||||
|
@ -283,10 +283,10 @@ Optional<HttpRequest::Header> HttpRequest::get_http_basic_authentication_header(
|
|||
builder.clear();
|
||||
builder.append("Basic "sv);
|
||||
builder.append(token);
|
||||
return Header { "Authorization", builder.to_deprecated_string() };
|
||||
return Header { "Authorization", builder.to_byte_string() };
|
||||
}
|
||||
|
||||
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(DeprecatedString const& value)
|
||||
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(ByteString const& value)
|
||||
{
|
||||
if (!value.starts_with("Basic "sv, AK::CaseSensitivity::CaseInsensitive))
|
||||
return {};
|
||||
|
@ -296,7 +296,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 = DeprecatedString::copy(decoded_token_bb.value());
|
||||
auto decoded_token = ByteString::copy(decoded_token_bb.value());
|
||||
auto colon_index = decoded_token.find(':');
|
||||
if (!colon_index.has_value())
|
||||
return {};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -56,19 +56,19 @@ public:
|
|||
};
|
||||
|
||||
struct Header {
|
||||
DeprecatedString name;
|
||||
DeprecatedString value;
|
||||
ByteString name;
|
||||
ByteString value;
|
||||
};
|
||||
|
||||
struct BasicAuthenticationCredentials {
|
||||
DeprecatedString username;
|
||||
DeprecatedString password;
|
||||
ByteString username;
|
||||
ByteString password;
|
||||
};
|
||||
|
||||
HttpRequest() = default;
|
||||
~HttpRequest() = default;
|
||||
|
||||
DeprecatedString const& resource() const { return m_resource; }
|
||||
ByteString const& resource() const { return m_resource; }
|
||||
Vector<Header> const& headers() const { return m_headers; }
|
||||
|
||||
URL const& url() const { return m_url; }
|
||||
|
@ -83,15 +83,15 @@ public:
|
|||
StringView method_name() const;
|
||||
ErrorOr<ByteBuffer> to_raw_request() const;
|
||||
|
||||
void set_headers(HashMap<DeprecatedString, DeprecatedString> const&);
|
||||
void set_headers(HashMap<ByteString, ByteString> const&);
|
||||
|
||||
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
|
||||
static Optional<Header> get_http_basic_authentication_header(URL const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(DeprecatedString const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(ByteString const&);
|
||||
|
||||
private:
|
||||
URL m_url;
|
||||
DeprecatedString m_resource;
|
||||
ByteString m_resource;
|
||||
Method m_method { GET };
|
||||
Vector<Header> m_headers;
|
||||
ByteBuffer m_body;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
HttpResponse::HttpResponse(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&& headers, size_t size)
|
||||
HttpResponse::HttpResponse(int code, HashMap<ByteString, ByteString, CaseInsensitiveStringTraits>&& headers, size_t size)
|
||||
: m_code(code)
|
||||
, m_headers(move(headers))
|
||||
, m_downloaded_size(size)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibCore/NetworkResponse.h>
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace HTTP {
|
|||
class HttpResponse : public Core::NetworkResponse {
|
||||
public:
|
||||
virtual ~HttpResponse() override = default;
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&& headers, size_t downloaded_size)
|
||||
static NonnullRefPtr<HttpResponse> create(int code, HashMap<ByteString, ByteString, 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<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
||||
|
||||
static StringView reason_phrase_for_code(int code);
|
||||
|
||||
private:
|
||||
HttpResponse(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&&, size_t size);
|
||||
HttpResponse(int code, HashMap<ByteString, ByteString, CaseInsensitiveStringTraits>&&, size_t size);
|
||||
|
||||
int m_code { 0 };
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> m_headers;
|
||||
size_t m_downloaded_size { 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
void HttpsJob::set_certificate(DeprecatedString certificate, DeprecatedString key)
|
||||
void HttpsJob::set_certificate(ByteString certificate, ByteString key)
|
||||
{
|
||||
m_received_client_certificates = TLS::TLSv12::parse_pem_certificate(certificate.bytes(), key.bytes());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,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(DeprecatedString certificate, DeprecatedString key);
|
||||
void set_certificate(ByteString certificate, ByteString key);
|
||||
|
||||
Function<Vector<TLS::Certificate>()> on_certificate_requested;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace HTTP {
|
||||
|
||||
static ErrorOr<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, DeprecatedString const& content_encoding)
|
||||
static ErrorOr<ByteBuffer> handle_content_encoding(ByteBuffer const& buf, ByteString const& content_encoding)
|
||||
{
|
||||
dbgln_if(JOB_DEBUG, "Job::handle_content_encoding: buf has content_encoding={}", content_encoding);
|
||||
|
||||
|
@ -173,11 +173,11 @@ void Job::register_on_ready_to_read(Function<void()> callback)
|
|||
};
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Job::read_line(size_t size)
|
||||
ErrorOr<ByteString> 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 DeprecatedString::copy(bytes_read);
|
||||
return ByteString::copy(bytes_read);
|
||||
}
|
||||
|
||||
ErrorOr<ByteBuffer> Job::receive(size_t size)
|
||||
|
@ -203,7 +203,7 @@ void Job::on_socket_connected()
|
|||
|
||||
if constexpr (JOB_DEBUG) {
|
||||
dbgln("Job: raw_request:");
|
||||
dbgln("{}", DeprecatedString::copy(raw_request));
|
||||
dbgln("{}", ByteString::copy(raw_request));
|
||||
}
|
||||
|
||||
bool success = !m_socket->write_until_depleted(raw_request).is_error();
|
||||
|
@ -304,7 +304,7 @@ void Job::on_socket_connected()
|
|||
}
|
||||
if (on_headers_received) {
|
||||
if (!m_set_cookie_headers.is_empty())
|
||||
m_headers.set("Set-Cookie", JsonArray { m_set_cookie_headers }.to_deprecated_string());
|
||||
m_headers.set("Set-Cookie", JsonArray { m_set_cookie_headers }.to_byte_string());
|
||||
on_headers_received(m_headers, m_code > 0 ? m_code : Optional<u32> {});
|
||||
}
|
||||
m_state = State::InBody;
|
||||
|
@ -361,7 +361,7 @@ void Job::on_socket_connected()
|
|||
builder.append(existing_value.value());
|
||||
builder.append(',');
|
||||
builder.append(value);
|
||||
m_headers.set(name, builder.to_deprecated_string());
|
||||
m_headers.set(name, builder.to_byte_string());
|
||||
} else {
|
||||
m_headers.set(name, value);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ void Job::on_socket_connected()
|
|||
break;
|
||||
} else {
|
||||
auto chunk = size_lines[0].split_view(';', SplitBehavior::KeepEmpty);
|
||||
DeprecatedString size_string = chunk[0];
|
||||
ByteString size_string = chunk[0];
|
||||
char* endptr;
|
||||
auto size = strtoul(size_string.characters(), &endptr, 16);
|
||||
if (*endptr) {
|
||||
|
|
|
@ -36,7 +36,7 @@ protected:
|
|||
void on_socket_connected();
|
||||
void flush_received_buffers();
|
||||
void register_on_ready_to_read(Function<void()>);
|
||||
ErrorOr<DeprecatedString> read_line(size_t);
|
||||
ErrorOr<ByteString> read_line(size_t);
|
||||
ErrorOr<ByteBuffer> receive(size_t);
|
||||
void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
|
@ -53,8 +53,8 @@ protected:
|
|||
Core::BufferedSocketBase* m_socket { nullptr };
|
||||
bool m_legacy_connection { false };
|
||||
int m_code { -1 };
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<DeprecatedString> m_set_cookie_headers;
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<ByteString> m_set_cookie_headers;
|
||||
|
||||
struct ReceivedBuffer {
|
||||
ReceivedBuffer(ByteBuffer d)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue