mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibWeb: Support for Access-Control-Expose-Headers in Fetch
This adds the headers named in Access-Control-Expose-Headers to the response's CORS-exposed header-name list which allows those headers to be accessed from JS.
This commit is contained in:
parent
15440b156f
commit
3a1f510af0
3 changed files with 36 additions and 7 deletions
|
@ -53,6 +53,23 @@ JS::NonnullGCPtr<HeaderList> HeaderList::create(JS::VM& vm)
|
|||
return vm.heap().allocate_without_realm<HeaderList>();
|
||||
}
|
||||
|
||||
// Non-standard
|
||||
ErrorOr<Vector<ByteBuffer>> HeaderList::unique_names() const
|
||||
{
|
||||
Vector<ByteBuffer> header_names_set;
|
||||
HashTable<ReadonlyBytes, CaseInsensitiveBytesTraits<u8 const>> header_names_seen;
|
||||
|
||||
for (auto const& header : *this) {
|
||||
if (header_names_seen.contains(header.name))
|
||||
continue;
|
||||
auto bytes = TRY(ByteBuffer::copy(header.name));
|
||||
TRY(header_names_seen.try_set(header.name));
|
||||
TRY(header_names_set.try_append(move(bytes)));
|
||||
}
|
||||
|
||||
return header_names_set;
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#header-list-contains
|
||||
bool HeaderList::contains(ReadonlyBytes name) const
|
||||
{
|
||||
|
|
|
@ -61,6 +61,8 @@ public:
|
|||
[[nodiscard]] ErrorOr<ExtractLengthResult> extract_length() const;
|
||||
|
||||
[[nodiscard]] ErrorOr<Optional<MimeSniff::MimeType>> extract_mime_type() const;
|
||||
|
||||
ErrorOr<Vector<ByteBuffer>> unique_names() const;
|
||||
};
|
||||
|
||||
struct RangeHeaderValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue