ConnectionInfo.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/Object.h>
  10. #include <LibCore/TCPSocket.h>
  11. #include <LibTLS/TLSv12.h>
  12. #include <LibWebSocket/Message.h>
  13. namespace WebSocket {
  14. class ConnectionInfo final {
  15. public:
  16. ConnectionInfo(URL);
  17. URL const& url() const { return m_url; }
  18. String const& origin() const { return m_origin; }
  19. void set_origin(String origin) { m_origin = move(origin); }
  20. Vector<String> const& protocols() const { return m_protocols; }
  21. void set_protocols(Vector<String> protocols) { m_protocols = move(protocols); }
  22. Vector<String> const& extensions() const { return m_extensions; }
  23. void set_extensions(Vector<String> extensions) { m_extensions = move(extensions); }
  24. struct Header {
  25. String name;
  26. String value;
  27. };
  28. Vector<Header> const& headers() const { return m_headers; }
  29. void set_headers(Vector<Header> headers) { m_headers = move(headers); }
  30. // secure flag - defined in RFC 6455 Section 3
  31. bool is_secure() const;
  32. // "resource-name" or "/resource name/" - defined in RFC 6455 Section 3
  33. String resource_name() const;
  34. private:
  35. URL m_url;
  36. String m_origin;
  37. Vector<String> m_protocols {};
  38. Vector<String> m_extensions {};
  39. Vector<Header> m_headers {};
  40. };
  41. }