2021-04-17 15:20:24 +00:00
|
|
|
/*
|
2021-04-25 09:30:39 +00:00
|
|
|
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
|
2021-04-17 15:20:24 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-17 15:20:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/URL.h>
|
|
|
|
#include <AK/Vector.h>
|
2023-08-06 16:09:39 +00:00
|
|
|
#include <LibCore/EventReceiver.h>
|
2021-04-17 15:20:24 +00:00
|
|
|
#include <LibTLS/TLSv12.h>
|
|
|
|
#include <LibWebSocket/Message.h>
|
|
|
|
|
|
|
|
namespace WebSocket {
|
|
|
|
|
|
|
|
class ConnectionInfo final {
|
|
|
|
public:
|
|
|
|
ConnectionInfo(URL);
|
|
|
|
|
|
|
|
URL const& url() const { return m_url; }
|
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString const& origin() const { return m_origin; }
|
|
|
|
void set_origin(ByteString origin) { m_origin = move(origin); }
|
2021-04-17 15:20:24 +00:00
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
Vector<ByteString> const& protocols() const { return m_protocols; }
|
|
|
|
void set_protocols(Vector<ByteString> protocols) { m_protocols = move(protocols); }
|
2021-04-17 15:20:24 +00:00
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
Vector<ByteString> const& extensions() const { return m_extensions; }
|
|
|
|
void set_extensions(Vector<ByteString> extensions) { m_extensions = move(extensions); }
|
2021-04-17 15:20:24 +00:00
|
|
|
|
|
|
|
struct Header {
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString name;
|
|
|
|
ByteString value;
|
2021-04-17 15:20:24 +00:00
|
|
|
};
|
|
|
|
Vector<Header> const& headers() const { return m_headers; }
|
|
|
|
void set_headers(Vector<Header> headers) { m_headers = move(headers); }
|
|
|
|
|
|
|
|
// secure flag - defined in RFC 6455 Section 3
|
|
|
|
bool is_secure() const;
|
|
|
|
|
|
|
|
// "resource-name" or "/resource name/" - defined in RFC 6455 Section 3
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString resource_name() const;
|
2021-04-17 15:20:24 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
URL m_url;
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString m_origin;
|
|
|
|
Vector<ByteString> m_protocols {};
|
|
|
|
Vector<ByteString> m_extensions {};
|
2021-04-17 15:20:24 +00:00
|
|
|
Vector<Header> m_headers {};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|