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>>, IEnumerableConstructors
| Name | Description |
|---|---|
| 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.csHeaders(IEnumerable<IReadOnlyList<string>>)
Headers.csCreates 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.csCreates a list from the entries of a record (record<ByteString, ByteString>).
public Headers(IEnumerable<KeyValuePair<string, string>> init)Parameters
See also
Methods
| Name | Description |
|---|---|
| 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.csDelete(string)
Headers.csRemoves the headers with the name (https://fetch.spec.whatwg.org/#dom-headers-delete).
Get(string)
Headers.csReturns the values of the headers with the name, separated by ", ", or null (https://fetch.spec.whatwg.org/#dom-headers-get).
GetEnumerator()
Headers.csReturns 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.csReturns the values of the Set-Cookie headers (https://fetch.spec.whatwg.org/#dom-headers-getsetcookie).
public IReadOnlyList<string> GetSetCookie()Has(string)
Headers.csReturns whether there is a header with the name (https://fetch.spec.whatwg.org/#dom-headers-has).