Table of Contents

Class ETagHelper

Namespace
Trellis.Asp
Assembly
Trellis.Asp.dll

RFC 9110-compliant entity tag comparison helpers.

public static class ETagHelper
Inheritance
ETagHelper
Inherited Members

Methods

IfMatchSatisfied(IList<EntityTagHeaderValue>, string)

Checks whether the If-Match header matches the current ETag using strong comparison per RFC 9110 §13.1.1.

public static bool IfMatchSatisfied(IList<EntityTagHeaderValue> ifMatchHeader, string currentETag)

Parameters

ifMatchHeader IList<EntityTagHeaderValue>

Raw If-Match header values.

currentETag string

The current resource ETag (unquoted).

Returns

bool

true if the precondition is satisfied (request should proceed).

IfNoneMatchMatches(IList<EntityTagHeaderValue>, string)

Checks whether the If-None-Match header matches the current ETag using weak comparison per RFC 9110 §13.1.2.

public static bool IfNoneMatchMatches(IList<EntityTagHeaderValue> ifNoneMatchHeader, string currentETag)

Parameters

ifNoneMatchHeader IList<EntityTagHeaderValue>

Raw If-None-Match header values.

currentETag string

The current resource ETag (unquoted).

Returns

bool

true if any tag matches (meaning 304 should be returned).

ParseIfMatch(HttpRequest)

Parses the If-Match header from an HTTP request and returns EntityTagValue instances for use with OptionalETag/RequireETag.

public static EntityTagValue[]? ParseIfMatch(HttpRequest request)

Parameters

request HttpRequest

The HTTP request containing the If-Match header.

Returns

EntityTagValue[]

null if no If-Match header is present; an array of EntityTagValue instances (weak tags excluded per §13.1.1); an empty array if the header is present but contains only weak tags.

ParseIfModifiedSince(HttpRequest)

Parses the If-Modified-Since header.

public static DateTimeOffset? ParseIfModifiedSince(HttpRequest request)

Parameters

request HttpRequest

Returns

DateTimeOffset?

ParseIfNoneMatch(HttpRequest)

Parses the If-None-Match header from an HTTP request.

public static EntityTagValue[]? ParseIfNoneMatch(HttpRequest request)

Parameters

request HttpRequest

Returns

EntityTagValue[]

null if absent; a wildcard EntityTagValue if wildcard; array of entity tag values (both strong and weak).

ParseIfUnmodifiedSince(HttpRequest)

Parses the If-Unmodified-Since header.

public static DateTimeOffset? ParseIfUnmodifiedSince(HttpRequest request)

Parameters

request HttpRequest

Returns

DateTimeOffset?