Skip to content

Truly independent web browser

1.8 KB
Raw Blame
/*
 * Copyright (c) 2021, Dex♪ <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Vector.h>
#include <LibHTTP/HeaderList.h>
#include <LibURL/URL.h>

namespace DNS {

class LookupResult;

}

namespace WebSocket {

class ConnectionInfo final {
public:
    ConnectionInfo(URL::URL);
    ConnectionInfo(ConnectionInfo const&);
    ConnectionInfo(ConnectionInfo&&);
    ConnectionInfo& operator=(ConnectionInfo const&);
    ConnectionInfo& operator=(ConnectionInfo&&);
    ~ConnectionInfo();

    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;
    void set_dns_result(NonnullRefPtr<DNS::LookupResult 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;
};

}