LinkHeaderValueExtensions Class

Provides extension methods for working with Link header values.

public static class LinkHeaderValueExtensions

Methods

NameDescription
EnumerateLinkHeaders(HttpHeaders)Enumerates all Link header values from HTTP headers.
GetLink(IEnumerable<LinkHeaderValue>, string)Gets the first link declaring the specified relation type.
GetLinkUrl(IEnumerable<LinkHeaderValue>, string)Gets the URL of the first link with the specified relation type.

EnumerateLinkHeaders(HttpHeaders)

LinkHeaderValueExtensions.cs

Enumerates all Link header values from HTTP headers.

public static IEnumerable<LinkHeaderValue> EnumerateLinkHeaders(this HttpHeaders headers)

Parameters

headers HttpHeaders
The HTTP headers to parse.

Returns

IEnumerable<LinkHeaderValue> A collection of LinkHeaderValue instances.

GetLink(IEnumerable<LinkHeaderValue>, string)

LinkHeaderValueExtensions.cs

Gets the first link declaring the specified relation type.

public static LinkHeaderValue? GetLink(this IEnumerable<LinkHeaderValue> links, string rel)

Parameters

links IEnumerable<LinkHeaderValue>
The collection of links to search.
rel string
The relation type to find. A link matches when LinkHeaderValue.Rel contains this relation type, which may be one of several space-separated values.

Returns

LinkHeaderValue? The first LinkHeaderValue with the specified relation type, or null if not found.

GetLinkUrl(IEnumerable<LinkHeaderValue>, string)

LinkHeaderValueExtensions.cs

Gets the URL of the first link with the specified relation type.

public static string? GetLinkUrl(this IEnumerable<LinkHeaderValue> links, string rel)

Parameters

links IEnumerable<LinkHeaderValue>
The collection of links to search.
rel string
The relation type to find.

Returns

string? The URL of the first link with the specified relation type, or null if not found.