mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibWeb: Implement '5.1. Headers class' from the Fetch API :^)
This commit is contained in:
parent
b5ab1f6b4a
commit
ed49b66f25
9 changed files with 516 additions and 0 deletions
47
Userland/Libraries/LibWeb/Fetch/HeadersIterator.h
Normal file
47
Userland/Libraries/LibWeb/Fetch/HeadersIterator.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/Fetch/Headers.h>
|
||||
|
||||
namespace Web::Fetch {
|
||||
|
||||
class HeadersIterator
|
||||
: public Bindings::Wrappable
|
||||
, public RefCounted<HeadersIterator> {
|
||||
public:
|
||||
using WrapperType = Bindings::HeadersIteratorWrapper;
|
||||
|
||||
static NonnullRefPtr<HeadersIterator> create(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
{
|
||||
return adopt_ref(*new HeadersIterator(headers, iteration_kind));
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Object*> next();
|
||||
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
||||
private:
|
||||
HeadersIterator(Headers const& headers, JS::Object::PropertyKind iteration_kind)
|
||||
: m_headers(headers)
|
||||
, m_iteration_kind(iteration_kind)
|
||||
{
|
||||
}
|
||||
|
||||
Headers const& m_headers;
|
||||
JS::Object::PropertyKind m_iteration_kind;
|
||||
size_t m_index { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
HeadersIteratorWrapper* wrap(JS::GlobalObject&, Fetch::HeadersIterator&);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue