mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:08:12 +00:00
LibWeb: Make HeaderList ref-counted
This is needed to eventually share a header list between a Request or Response object's internal infra request/response and the object's exposed Header object.
This commit is contained in:
parent
2d57d47132
commit
afe2563e2b
8 changed files with 61 additions and 46 deletions
|
@ -47,7 +47,7 @@ public:
|
|||
[[nodiscard]] static NonnullOwnPtr<Response> aborted_network_error();
|
||||
[[nodiscard]] static NonnullOwnPtr<Response> network_error();
|
||||
|
||||
Response() = default;
|
||||
Response();
|
||||
virtual ~Response() = default;
|
||||
|
||||
[[nodiscard]] virtual Type type() const { return m_type; }
|
||||
|
@ -66,9 +66,9 @@ public:
|
|||
[[nodiscard]] virtual ReadonlyBytes status_message() const { return m_status_message; }
|
||||
void set_status_message(ByteBuffer status_message) { m_status_message = move(status_message); }
|
||||
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const { return m_header_list; }
|
||||
[[nodiscard]] HeaderList& header_list() { return m_header_list; }
|
||||
void set_header_list(HeaderList header_list) { m_header_list = move(header_list); }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const { return m_header_list; }
|
||||
[[nodiscard]] NonnullRefPtr<HeaderList>& header_list() { return m_header_list; }
|
||||
void set_header_list(NonnullRefPtr<HeaderList> header_list) { m_header_list = move(header_list); }
|
||||
|
||||
[[nodiscard]] virtual Optional<Body> const& body() const { return m_body; }
|
||||
[[nodiscard]] Optional<Body>& body() { return m_body; }
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-response-header-list
|
||||
// A response has an associated header list (a header list). Unless stated otherwise it is empty.
|
||||
HeaderList m_header_list;
|
||||
NonnullRefPtr<HeaderList> m_header_list;
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-response-body
|
||||
// A response has an associated body (null or a body). Unless stated otherwise it is null.
|
||||
|
@ -169,7 +169,7 @@ public:
|
|||
[[nodiscard]] virtual Vector<AK::URL> const& url_list() const override { return m_internal_response.url_list(); }
|
||||
[[nodiscard]] virtual Status status() const override { return m_internal_response.status(); }
|
||||
[[nodiscard]] virtual ReadonlyBytes status_message() const override { return m_internal_response.status_message(); }
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const override { return m_internal_response.header_list(); }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const override { return m_internal_response.header_list(); }
|
||||
[[nodiscard]] virtual Optional<Body> const& body() const override { return m_internal_response.body(); }
|
||||
[[nodiscard]] virtual Optional<CacheState> const& cache_state() const override { return m_internal_response.cache_state(); }
|
||||
[[nodiscard]] virtual Vector<ByteBuffer> const& cors_exposed_header_name_list() const override { return m_internal_response.cors_exposed_header_name_list(); }
|
||||
|
@ -192,12 +192,12 @@ public:
|
|||
static ErrorOr<NonnullOwnPtr<BasicFilteredResponse>> create(Response&);
|
||||
|
||||
[[nodiscard]] virtual Type type() const override { return Type::Basic; }
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const override { return m_header_list; }
|
||||
|
||||
private:
|
||||
BasicFilteredResponse(Response&, HeaderList);
|
||||
BasicFilteredResponse(Response&, NonnullRefPtr<HeaderList>);
|
||||
|
||||
HeaderList m_header_list;
|
||||
NonnullRefPtr<HeaderList> m_header_list;
|
||||
};
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-filtered-response-cors
|
||||
|
@ -206,12 +206,12 @@ public:
|
|||
static ErrorOr<NonnullOwnPtr<CORSFilteredResponse>> create(Response&);
|
||||
|
||||
[[nodiscard]] virtual Type type() const override { return Type::CORS; }
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const override { return m_header_list; }
|
||||
|
||||
private:
|
||||
CORSFilteredResponse(Response&, HeaderList);
|
||||
CORSFilteredResponse(Response&, NonnullRefPtr<HeaderList>);
|
||||
|
||||
HeaderList m_header_list;
|
||||
NonnullRefPtr<HeaderList> m_header_list;
|
||||
};
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-filtered-response-opaque
|
||||
|
@ -223,14 +223,14 @@ public:
|
|||
[[nodiscard]] virtual Vector<AK::URL> const& url_list() const override { return m_url_list; }
|
||||
[[nodiscard]] virtual Status status() const override { return 0; }
|
||||
[[nodiscard]] virtual ReadonlyBytes status_message() const override { return {}; }
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual Optional<Body> const& body() const override { return m_body; }
|
||||
|
||||
private:
|
||||
explicit OpaqueFilteredResponse(Response&);
|
||||
|
||||
Vector<AK::URL> m_url_list;
|
||||
HeaderList m_header_list;
|
||||
NonnullRefPtr<HeaderList> m_header_list;
|
||||
Optional<Body> m_body;
|
||||
};
|
||||
|
||||
|
@ -242,13 +242,13 @@ public:
|
|||
[[nodiscard]] virtual Type type() const override { return Type::OpaqueRedirect; }
|
||||
[[nodiscard]] virtual Status status() const override { return 0; }
|
||||
[[nodiscard]] virtual ReadonlyBytes status_message() const override { return {}; }
|
||||
[[nodiscard]] virtual HeaderList const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual NonnullRefPtr<HeaderList> const& header_list() const override { return m_header_list; }
|
||||
[[nodiscard]] virtual Optional<Body> const& body() const override { return m_body; }
|
||||
|
||||
private:
|
||||
explicit OpaqueRedirectFilteredResponse(Response&);
|
||||
|
||||
HeaderList m_header_list;
|
||||
NonnullRefPtr<HeaderList> m_header_list;
|
||||
Optional<Body> m_body;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue