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

@ -20,7 +20,7 @@ bool ConnectionInfo::is_secure() const
return m_url.scheme().equals_ignoring_case("wss"sv);
}
String ConnectionInfo::resource_name() const
DeprecatedString ConnectionInfo::resource_name() const
{
// RFC 6455 Section 3 :
// The "resource-name" can be constructed by concatenating the following:

View file

@ -20,18 +20,18 @@ public:
URL const& url() const { return m_url; }
String const& origin() const { return m_origin; }
void set_origin(String origin) { m_origin = move(origin); }
DeprecatedString const& origin() const { return m_origin; }
void set_origin(DeprecatedString origin) { m_origin = move(origin); }
Vector<String> const& protocols() const { return m_protocols; }
void set_protocols(Vector<String> protocols) { m_protocols = move(protocols); }
Vector<DeprecatedString> const& protocols() const { return m_protocols; }
void set_protocols(Vector<DeprecatedString> protocols) { m_protocols = move(protocols); }
Vector<String> const& extensions() const { return m_extensions; }
void set_extensions(Vector<String> extensions) { m_extensions = move(extensions); }
Vector<DeprecatedString> const& extensions() const { return m_extensions; }
void set_extensions(Vector<DeprecatedString> extensions) { m_extensions = move(extensions); }
struct Header {
String name;
String value;
DeprecatedString name;
DeprecatedString value;
};
Vector<Header> const& headers() const { return m_headers; }
void set_headers(Vector<Header> headers) { m_headers = move(headers); }
@ -40,13 +40,13 @@ public:
bool is_secure() const;
// "resource-name" or "/resource name/" - defined in RFC 6455 Section 3
String resource_name() const;
DeprecatedString resource_name() const;
private:
URL m_url;
String m_origin;
Vector<String> m_protocols {};
Vector<String> m_extensions {};
DeprecatedString m_origin;
Vector<DeprecatedString> m_protocols {};
Vector<DeprecatedString> m_extensions {};
Vector<Header> m_headers {};
};

View file

@ -9,8 +9,8 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Span.h>
#include <AK/String.h>
#include <LibWebSocket/ConnectionInfo.h>
namespace WebSocket {
@ -21,7 +21,7 @@ public:
virtual void connect(ConnectionInfo const&) = 0;
virtual bool can_read_line() = 0;
virtual ErrorOr<String> read_line(size_t) = 0;
virtual ErrorOr<DeprecatedString> read_line(size_t) = 0;
virtual ErrorOr<ByteBuffer> read(int max_size) = 0;
virtual bool send(ReadonlyBytes) = 0;
virtual bool eof() = 0;

View file

@ -79,7 +79,7 @@ ErrorOr<ByteBuffer> WebSocketImplSerenity::read(int max_size)
return buffer.slice(0, read_bytes.size());
}
ErrorOr<String> WebSocketImplSerenity::read_line(size_t size)
ErrorOr<DeprecatedString> WebSocketImplSerenity::read_line(size_t size)
{
auto buffer = TRY(ByteBuffer::create_uninitialized(size));
auto line = TRY(m_socket->read_line(buffer));

View file

@ -19,7 +19,7 @@ public:
virtual void connect(ConnectionInfo const&) override;
virtual bool can_read_line() override;
virtual ErrorOr<String> read_line(size_t) override;
virtual ErrorOr<DeprecatedString> read_line(size_t) override;
virtual ErrorOr<ByteBuffer> read(int max_size) override;
virtual bool send(ReadonlyBytes) override;
virtual bool eof() override;

View file

@ -7,14 +7,14 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
namespace WebSocket {
class Message {
public:
explicit Message(String const& data)
explicit Message(DeprecatedString const& data)
: m_is_text(true)
, m_data(ByteBuffer::copy(data.bytes()).release_value_but_fixme_should_propagate_errors()) // FIXME: Handle possible OOM situation.
{

View file

@ -85,7 +85,7 @@ void WebSocket::send(Message const& message)
send_frame(WebSocket::OpCode::Binary, message.data(), true);
}
void WebSocket::close(u16 code, String const& message)
void WebSocket::close(u16 code, DeprecatedString const& message)
{
VERIFY(m_impl);
@ -316,7 +316,7 @@ void WebSocket::read_server_handshake()
if (header_name.equals_ignoring_case("Sec-WebSocket-Accept"sv)) {
// 4. |Sec-WebSocket-Accept| should be base64(SHA1(|Sec-WebSocket-Key| + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
auto expected_content = String::formatted("{}258EAFA5-E914-47DA-95CA-C5AB0DC85B11", m_websocket_key);
auto expected_content = DeprecatedString::formatted("{}258EAFA5-E914-47DA-95CA-C5AB0DC85B11", m_websocket_key);
Crypto::Hash::Manager hash;
hash.initialize(Crypto::Hash::HashKind::SHA1);
@ -484,7 +484,7 @@ void WebSocket::read_frame()
if (op_code == WebSocket::OpCode::ConnectionClose) {
if (payload.size() > 1) {
m_last_close_code = (((u16)(payload[0] & 0xff) << 8) | ((u16)(payload[1] & 0xff)));
m_last_close_message = String(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
m_last_close_message = DeprecatedString(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
}
m_state = WebSocket::InternalState::Closing;
return;
@ -618,7 +618,7 @@ void WebSocket::notify_open()
on_open();
}
void WebSocket::notify_close(u16 code, String reason, bool was_clean)
void WebSocket::notify_close(u16 code, DeprecatedString reason, bool was_clean)
{
if (!on_close)
return;

View file

@ -39,10 +39,10 @@ public:
void send(Message const&);
// This can only be used if the `ready_state` is `ReadyState::Open`
void close(u16 code = 1005, String const& reason = {});
void close(u16 code = 1005, DeprecatedString const& reason = {});
Function<void()> on_open;
Function<void(u16 code, String reason, bool was_clean)> on_close;
Function<void(u16 code, DeprecatedString reason, bool was_clean)> on_close;
Function<void(Message message)> on_message;
enum class Error {
@ -75,7 +75,7 @@ private:
void send_frame(OpCode, ReadonlyBytes, bool is_final);
void notify_open();
void notify_close(u16 code, String reason, bool was_clean);
void notify_close(u16 code, DeprecatedString reason, bool was_clean);
void notify_error(Error);
void notify_message(Message);
@ -95,14 +95,14 @@ private:
InternalState m_state { InternalState::NotStarted };
String m_websocket_key;
DeprecatedString m_websocket_key;
bool m_has_read_server_handshake_first_line { false };
bool m_has_read_server_handshake_upgrade { false };
bool m_has_read_server_handshake_connection { false };
bool m_has_read_server_handshake_accept { false };
u16 m_last_close_code { 1005 };
String m_last_close_message;
DeprecatedString m_last_close_message;
ConnectionInfo m_connection;
RefPtr<WebSocketImpl> m_impl;