Headers Class

A list of HTTP headers (https://fetch.spec.whatwg.org/#headers-class): the headers of a request or a response of the Fetch API, or a list created by new Headers(). The names and the values are byte strings (each character is a byte, in the range U+0000 to U+00FF). The names are compared ASCII case-insensitively, and the iteration returns the lowercase names, sorted, with the values of the headers with the same name combined (except Set-Cookie).

public sealed class Headers : IEnumerable<KeyValuePair<string, string>>, IEnumerable
Implements

Constructors

NameDescription
Headers()Creates an empty list.
Headers(IEnumerable<IReadOnlyList<string>>)Creates a list from pairs of a name and a value (sequence<sequence<ByteString>>).
Headers(IEnumerable<KeyValuePair<string, string>>)Creates a list from the entries of a record (record<ByteString, ByteString>).

Headers overloads

Headers()

Headers.cs

Creates an empty list.

public Headers()

Headers(IEnumerable<IReadOnlyList<string>>)

Headers.cs

Creates a list from pairs of a name and a value (sequence<sequence<ByteString>>).

public Headers(IEnumerable<IReadOnlyList<string>> init)

Headers(IEnumerable<KeyValuePair<string, string>>)

Headers.cs

Creates a list from the entries of a record (record<ByteString, ByteString>).

public Headers(IEnumerable<KeyValuePair<string, string>> init)

Methods

NameDescription
Append(string, string)Appends a header (https://fetch.spec.whatwg.org/#dom-headers-append).
Delete(string)Removes the headers with the name (https://fetch.spec.whatwg.org/#dom-headers-delete).
Get(string)Returns the values of the headers with the name, separated by ", ", or null (https://fetch.spec.whatwg.org/#dom-headers-get).
GetEnumerator()Returns the headers sorted by name, with the values of the headers with the same name combined (https://fetch.spec.whatwg.org/#ref-for-dfn-iterable-1).
GetSetCookie()Returns the values of the Set-Cookie headers (https://fetch.spec.whatwg.org/#dom-headers-getsetcookie).
Has(string)Returns whether there is a header with the name (https://fetch.spec.whatwg.org/#dom-headers-has).
Set(string, string)Replaces the headers with the name (https://fetch.spec.whatwg.org/#dom-headers-set).
System.Collections.IEnumerable.GetEnumerator()

Append(string, string)

Headers.cs

Appends a header (https://fetch.spec.whatwg.org/#dom-headers-append).

public void Append(string name, string value)

Delete(string)

Headers.cs

Removes the headers with the name (https://fetch.spec.whatwg.org/#dom-headers-delete).

public void Delete(string name)

Get(string)

Headers.cs

Returns the values of the headers with the name, separated by ", ", or null (https://fetch.spec.whatwg.org/#dom-headers-get).

public string? Get(string name)

GetEnumerator()

Headers.cs

Returns the headers sorted by name, with the values of the headers with the same name combined (https://fetch.spec.whatwg.org/#ref-for-dfn-iterable-1).

public IEnumerator<KeyValuePair<string, string>> GetEnumerator()

GetSetCookie()

Headers.cs

Returns the values of the Set-Cookie headers (https://fetch.spec.whatwg.org/#dom-headers-getsetcookie).

public IReadOnlyList<string> GetSetCookie()

Has(string)

Headers.cs

Returns whether there is a header with the name (https://fetch.spec.whatwg.org/#dom-headers-has).

public bool Has(string name)

Set(string, string)

Headers.cs

Replaces the headers with the name (https://fetch.spec.whatwg.org/#dom-headers-set).

public void Set(string name, string value)

System.Collections.IEnumerable.GetEnumerator()

Headers.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.