mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +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
|
@ -20,7 +20,7 @@ bool ConnectionInfo::is_secure() const
|
|||
return m_url.scheme().bytes_as_string_view().equals_ignoring_ascii_case("wss"sv);
|
||||
}
|
||||
|
||||
DeprecatedString ConnectionInfo::resource_name() const
|
||||
ByteString ConnectionInfo::resource_name() const
|
||||
{
|
||||
// RFC 6455 Section 3 :
|
||||
// The "resource-name" can be constructed by concatenating the following:
|
||||
|
@ -37,7 +37,7 @@ DeprecatedString ConnectionInfo::resource_name() const
|
|||
// the query component
|
||||
builder.append(*m_url.query());
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,18 +20,18 @@ public:
|
|||
|
||||
URL const& url() const { return m_url; }
|
||||
|
||||
DeprecatedString const& origin() const { return m_origin; }
|
||||
void set_origin(DeprecatedString origin) { m_origin = move(origin); }
|
||||
ByteString const& origin() const { return m_origin; }
|
||||
void set_origin(ByteString origin) { m_origin = move(origin); }
|
||||
|
||||
Vector<DeprecatedString> const& protocols() const { return m_protocols; }
|
||||
void set_protocols(Vector<DeprecatedString> protocols) { m_protocols = move(protocols); }
|
||||
Vector<ByteString> const& protocols() const { return m_protocols; }
|
||||
void set_protocols(Vector<ByteString> protocols) { m_protocols = move(protocols); }
|
||||
|
||||
Vector<DeprecatedString> const& extensions() const { return m_extensions; }
|
||||
void set_extensions(Vector<DeprecatedString> extensions) { m_extensions = move(extensions); }
|
||||
Vector<ByteString> const& extensions() const { return m_extensions; }
|
||||
void set_extensions(Vector<ByteString> extensions) { m_extensions = move(extensions); }
|
||||
|
||||
struct Header {
|
||||
DeprecatedString name;
|
||||
DeprecatedString value;
|
||||
ByteString name;
|
||||
ByteString 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
|
||||
DeprecatedString resource_name() const;
|
||||
ByteString resource_name() const;
|
||||
|
||||
private:
|
||||
URL m_url;
|
||||
DeprecatedString m_origin;
|
||||
Vector<DeprecatedString> m_protocols {};
|
||||
Vector<DeprecatedString> m_extensions {};
|
||||
ByteString m_origin;
|
||||
Vector<ByteString> m_protocols {};
|
||||
Vector<ByteString> m_extensions {};
|
||||
Vector<Header> m_headers {};
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibWebSocket/ConnectionInfo.h>
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
virtual void connect(ConnectionInfo const&) = 0;
|
||||
virtual bool can_read_line() = 0;
|
||||
virtual ErrorOr<DeprecatedString> read_line(size_t) = 0;
|
||||
virtual ErrorOr<ByteString> read_line(size_t) = 0;
|
||||
virtual ErrorOr<ByteBuffer> read(int max_size) = 0;
|
||||
virtual bool send(ReadonlyBytes) = 0;
|
||||
virtual bool eof() = 0;
|
||||
|
|
|
@ -42,7 +42,7 @@ void WebSocketImplSerenity::connect(ConnectionInfo const& connection_info)
|
|||
VERIFY(on_connection_error);
|
||||
VERIFY(on_ready_to_read);
|
||||
auto socket_result = [&]() -> ErrorOr<NonnullOwnPtr<Core::BufferedSocketBase>> {
|
||||
auto host = TRY(connection_info.url().serialized_host()).to_deprecated_string();
|
||||
auto host = TRY(connection_info.url().serialized_host()).to_byte_string();
|
||||
if (connection_info.is_secure()) {
|
||||
TLS::Options options;
|
||||
options.set_alert_handler([this](auto) {
|
||||
|
@ -82,11 +82,11 @@ ErrorOr<ByteBuffer> WebSocketImplSerenity::read(int max_size)
|
|||
return buffer.slice(0, read_bytes.size());
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> WebSocketImplSerenity::read_line(size_t size)
|
||||
ErrorOr<ByteString> WebSocketImplSerenity::read_line(size_t size)
|
||||
{
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(size));
|
||||
auto line = TRY(m_socket->read_line(buffer));
|
||||
return line.to_deprecated_string();
|
||||
return line.to_byte_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
|
||||
virtual void connect(ConnectionInfo const&) override;
|
||||
virtual bool can_read_line() override;
|
||||
virtual ErrorOr<DeprecatedString> read_line(size_t) override;
|
||||
virtual ErrorOr<ByteString> read_line(size_t) override;
|
||||
virtual ErrorOr<ByteBuffer> read(int max_size) override;
|
||||
virtual bool send(ReadonlyBytes) override;
|
||||
virtual bool eof() override;
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
|
||||
namespace WebSocket {
|
||||
|
||||
class Message {
|
||||
public:
|
||||
explicit Message(DeprecatedString const& data)
|
||||
explicit Message(ByteString const& data)
|
||||
: m_is_text(true)
|
||||
, m_data(ByteBuffer::copy(data.bytes()).release_value_but_fixme_should_propagate_errors()) // FIXME: Handle possible OOM situation.
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ ReadyState WebSocket::ready_state()
|
|||
}
|
||||
}
|
||||
|
||||
DeprecatedString WebSocket::subprotocol_in_use()
|
||||
ByteString WebSocket::subprotocol_in_use()
|
||||
{
|
||||
return m_subprotocol_in_use;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void WebSocket::send(Message const& message)
|
|||
send_frame(WebSocket::OpCode::Binary, message.data(), true);
|
||||
}
|
||||
|
||||
void WebSocket::close(u16 code, DeprecatedString const& message)
|
||||
void WebSocket::close(u16 code, ByteString const& message)
|
||||
{
|
||||
VERIFY(m_impl);
|
||||
|
||||
|
@ -186,7 +186,7 @@ void WebSocket::send_client_handshake()
|
|||
u8 nonce_data[16];
|
||||
fill_with_random(nonce_data);
|
||||
// FIXME: change to TRY() and make method fallible
|
||||
m_websocket_key = MUST(encode_base64({ nonce_data, 16 })).to_deprecated_string();
|
||||
m_websocket_key = MUST(encode_base64({ nonce_data, 16 })).to_byte_string();
|
||||
builder.appendff("Sec-WebSocket-Key: {}\r\n", m_websocket_key);
|
||||
|
||||
// 8. Origin (optional field)
|
||||
|
@ -219,7 +219,7 @@ void WebSocket::send_client_handshake()
|
|||
builder.append("\r\n"sv);
|
||||
|
||||
m_state = WebSocket::InternalState::WaitingForServerHandshake;
|
||||
auto success = m_impl->send(builder.to_deprecated_string().bytes());
|
||||
auto success = m_impl->send(builder.to_byte_string().bytes());
|
||||
VERIFY(success);
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ void WebSocket::read_server_handshake()
|
|||
|
||||
if (header_name.equals_ignoring_ascii_case("Sec-WebSocket-Accept"sv)) {
|
||||
// 4. |Sec-WebSocket-Accept| should be base64(SHA1(|Sec-WebSocket-Key| + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
|
||||
auto expected_content = DeprecatedString::formatted("{}258EAFA5-E914-47DA-95CA-C5AB0DC85B11", m_websocket_key);
|
||||
auto expected_content = ByteString::formatted("{}258EAFA5-E914-47DA-95CA-C5AB0DC85B11", m_websocket_key);
|
||||
|
||||
Crypto::Hash::Manager hash;
|
||||
hash.initialize(Crypto::Hash::HashKind::SHA1);
|
||||
|
@ -485,7 +485,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 = DeprecatedString(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
|
||||
m_last_close_message = ByteString(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
|
||||
}
|
||||
m_state = WebSocket::InternalState::Closing;
|
||||
return;
|
||||
|
@ -632,7 +632,7 @@ void WebSocket::notify_open()
|
|||
on_open();
|
||||
}
|
||||
|
||||
void WebSocket::notify_close(u16 code, DeprecatedString reason, bool was_clean)
|
||||
void WebSocket::notify_close(u16 code, ByteString reason, bool was_clean)
|
||||
{
|
||||
if (!on_close)
|
||||
return;
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
ReadyState ready_state();
|
||||
|
||||
DeprecatedString subprotocol_in_use();
|
||||
ByteString subprotocol_in_use();
|
||||
|
||||
// Call this to start the WebSocket connection.
|
||||
void start();
|
||||
|
@ -41,10 +41,10 @@ public:
|
|||
void send(Message const&);
|
||||
|
||||
// This can only be used if the `ready_state` is `ReadyState::Open`
|
||||
void close(u16 code = 1005, DeprecatedString const& reason = {});
|
||||
void close(u16 code = 1005, ByteString const& reason = {});
|
||||
|
||||
Function<void()> on_open;
|
||||
Function<void(u16 code, DeprecatedString reason, bool was_clean)> on_close;
|
||||
Function<void(u16 code, ByteString reason, bool was_clean)> on_close;
|
||||
Function<void(Message message)> on_message;
|
||||
|
||||
enum class Error {
|
||||
|
@ -77,7 +77,7 @@ private:
|
|||
void send_frame(OpCode, ReadonlyBytes, bool is_final);
|
||||
|
||||
void notify_open();
|
||||
void notify_close(u16 code, DeprecatedString reason, bool was_clean);
|
||||
void notify_close(u16 code, ByteString reason, bool was_clean);
|
||||
void notify_error(Error);
|
||||
void notify_message(Message);
|
||||
|
||||
|
@ -97,16 +97,16 @@ private:
|
|||
|
||||
InternalState m_state { InternalState::NotStarted };
|
||||
|
||||
DeprecatedString m_subprotocol_in_use { DeprecatedString::empty() };
|
||||
ByteString m_subprotocol_in_use { ByteString::empty() };
|
||||
|
||||
DeprecatedString m_websocket_key;
|
||||
ByteString 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 };
|
||||
DeprecatedString m_last_close_message;
|
||||
ByteString m_last_close_message;
|
||||
|
||||
ConnectionInfo m_connection;
|
||||
RefPtr<WebSocketImpl> m_impl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue