/* * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::Fetch::Infrastructure { // https://fetch.spec.whatwg.org/#fetch-elsewhere-fetch class FetchAlgorithms : public JS::Cell { JS_CELL(FetchAlgorithms, JS::Cell); public: struct ConsumeBodyFailureTag { }; using ProcessRequestBodyChunkLengthFunction = JS::SafeFunction; using ProcessRequestEndOfBodyFunction = JS::SafeFunction; using ProcessEarlyHintsResponseFunction = JS::SafeFunction)>; using ProcessResponseFunction = JS::SafeFunction)>; using ProcessResponseEndOfBodyFunction = JS::SafeFunction)>; using ProcessResponseConsumeBodyFunction = JS::SafeFunction, Variant)>; struct Input { Optional process_request_body_chunk_length; Optional process_request_end_of_body; Optional process_early_hints_response; Optional process_response; Optional process_response_end_of_body; Optional process_response_consume_body; }; [[nodiscard]] static JS::NonnullGCPtr create(JS::VM&, Input); Optional const& process_request_body_chunk_length() const { return m_process_request_body_chunk_length; } Optional const& process_request_end_of_body() const { return m_process_request_end_of_body; } Optional const& process_early_hints_response() const { return m_process_early_hints_response; } Optional const& process_response() const { return m_process_response; } Optional const& process_response_end_of_body() const { return m_process_response_end_of_body; } Optional const& process_response_consume_body() const { return m_process_response_consume_body; } private: explicit FetchAlgorithms(Input); Optional m_process_request_body_chunk_length; Optional m_process_request_end_of_body; Optional m_process_early_hints_response; Optional m_process_response; Optional m_process_response_end_of_body; Optional m_process_response_consume_body; }; }