ConnectionInfo.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/URL.h>
  8. #include <AK/Vector.h>
  9. #include <LibCore/EventReceiver.h>
  10. #include <LibTLS/TLSv12.h>
  11. #include <LibWebSocket/Message.h>
  12. namespace WebSocket {
  13. class ConnectionInfo final {
  14. public:
  15. ConnectionInfo(URL);
  16. URL const& url() const { return m_url; }
  17. ByteString const& origin() const { return m_origin; }
  18. void set_origin(ByteString origin) { m_origin = move(origin); }
  19. Vector<ByteString> const& protocols() const { return m_protocols; }
  20. void set_protocols(Vector<ByteString> protocols) { m_protocols = move(protocols); }
  21. Vector<ByteString> const& extensions() const { return m_extensions; }
  22. void set_extensions(Vector<ByteString> extensions) { m_extensions = move(extensions); }
  23. struct Header {
  24. ByteString name;
  25. ByteString value;
  26. };
  27. Vector<Header> const& headers() const { return m_headers; }
  28. void set_headers(Vector<Header> headers) { m_headers = move(headers); }
  29. // secure flag - defined in RFC 6455 Section 3
  30. bool is_secure() const;
  31. // "resource-name" or "/resource name/" - defined in RFC 6455 Section 3
  32. ByteString resource_name() const;
  33. private:
  34. URL m_url;
  35. ByteString m_origin;
  36. Vector<ByteString> m_protocols {};
  37. Vector<ByteString> m_extensions {};
  38. Vector<Header> m_headers {};
  39. };
  40. }