ladybird/Libraries/LibWebSocket/ConnectionInfo.h
Timothy Flynn 9375660b64 LibHTTP+LibWeb+RequestServer: Move Fetch's HTTP header infra to LibHTTP
The end goal here is for LibHTTP to be the home of our RFC 9111 (HTTP
caching) implementation. We currently have one implementation in LibWeb
for our in-memory cache and another in RequestServer for our disk cache.

The implementations both largely revolve around interacting with HTTP
headers. But in LibWeb, we are using Fetch's header infra, and in RS we
are using are home-grown header infra from LibHTTP.

So to give these a common denominator, this patch replaces the LibHTTP
implementation with Fetch's infra. Our existing LibHTTP implementation
was not particularly compliant with any spec, so this at least gives us
a standards-based common implementation.

This migration also required moving a handful of other Fetch AOs over
to LibHTTP. (It turns out these AOs were all from the Fetch/Infra/HTTP
folder, so perhaps it makes sense for LibHTTP to be the implementation
of that entire set of facilities.)
2025-11-27 14:57:29 +01:00

56 lines
1.9 KiB
C++

/*
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibDNS/Resolver.h>
#include <LibHTTP/HeaderList.h>
#include <LibURL/URL.h>
namespace WebSocket {
class ConnectionInfo final {
public:
ConnectionInfo(URL::URL);
URL::URL const& url() const { return m_url; }
ByteString const& origin() const { return m_origin; }
void set_origin(ByteString origin) { m_origin = move(origin); }
Vector<ByteString> const& protocols() const { return m_protocols; }
void set_protocols(Vector<ByteString> protocols) { m_protocols = move(protocols); }
Vector<ByteString> const& extensions() const { return m_extensions; }
void set_extensions(Vector<ByteString> extensions) { m_extensions = move(extensions); }
HTTP::HeaderList const& headers() const { return m_headers; }
void set_headers(NonnullRefPtr<HTTP::HeaderList> headers) { m_headers = move(headers); }
Optional<ByteString> const& root_certificates_path() const { return m_root_certificates_path; }
void set_root_certificates_path(Optional<ByteString> root_certificates_path) { m_root_certificates_path = move(root_certificates_path); }
Optional<DNS::LookupResult const&> dns_result() const { return m_dns_result ? Optional<DNS::LookupResult const&>(*m_dns_result) : OptionalNone {}; }
void set_dns_result(NonnullRefPtr<DNS::LookupResult const> dns_result) { m_dns_result = move(dns_result); }
// secure flag - defined in RFC 6455 Section 3
bool is_secure() const;
// "resource-name" or "/resource name/" - defined in RFC 6455 Section 3
ByteString resource_name() const;
private:
URL::URL m_url;
ByteString m_origin;
Vector<ByteString> m_protocols {};
Vector<ByteString> m_extensions {};
NonnullRefPtr<HTTP::HeaderList> m_headers;
Optional<ByteString> m_root_certificates_path;
RefPtr<DNS::LookupResult const> m_dns_result;
};
}