src/packages/EmbedIO/HttpRequestExtensions.cs
/// <summary>
/// <para>Checks whether an <c>If-None-Match</c> header exists in a request
/// and, if so, whether it contains a given entity tag.</para>
/// <para>See <see href="https://tools.ietf.org/html/rfc7232#section-3.2">RFC7232, Section 3.2</see>
/// for a normative reference; however, see the Remarks section for more information
/// about the RFC compliance of this method.</para>
/// </summary>
/// <param name="this">The <see cref="IHttpRequest"/> on which this method is called.</param>
/// <param name="entityTag">The entity tag.</param>
/// <param name="headerExists">When this method returns, a value that indicates whether an
/// <c>If-None-Match</c> header is present in <paramref name="this"/>, regardless of the method's
/// return value. This parameter is passed uninitialized.</param>
/// <returns><see langword="true"/> if an <c>If-None-Match</c> header is present in
/// <paramref name="this"/> and one of the entity tags listed in it is equal to <paramref name="entityTag"/>;
/// <see langword="false"/> otherwise.</returns>
/// <remarks>
/// <para><see href="https://tools.ietf.org/html/rfc7232#section-3.2">RFC7232, Section 3.2</see>
/// states that a weak comparison function (as defined in
/// <see href="https://tools.ietf.org/html/rfc7232#section-2.3.2">RFC7232, Section 2.3.2</see>)
/// must be used for <c>If-None-Match</c>. That would mean parsing every entity tag, at least minimally,
/// to determine whether it is a "weak" or "strong" tag. Since EmbedIO currently generates only
/// "strong" tags, this method uses the default string comparer instead.</para>
/// <para>The behavior of this method is thus not, strictly speaking, RFC7232-compliant;
/// it works, though, with entity tags generated by EmbedIO.</para>
/// </remarks>
Checks whether an If-None-MatchSee RFC7232, Section 3.2
Checks whether an If - None - MatchSee RFC7232 Section 3 . 2
public static bool CheckIfNoneMatch(this IHttpRequest @this, string entityTag, out bool headerExists)
        {
            var values = @this.Headers.GetValues(HttpHeaderNames.IfNoneMatch);
            if (values == null)
            {
                headerExists = false;
                return false;
            }
            headerExists = true;
            return values.Select(t => t.Trim()).Contains(entityTag);
        }
public static bool CheckIfNoneMatch ( this IHttpRequest @this , string entityTag , out bool headerExists ) { var values = @this . Headers . GetValues ( HttpHeaderNames . IfNoneMatch ) ; if ( values == null ) { headerExists = false ; return false ; } headerExists = true ; return values . Select ( t => t . Trim ( ) ) . Contains ( entityTag ) ; }
Checks whether an If-None-MatchSee RFC7232, Section 3.2
Checks whether an If - None - MatchSee RFC7232 Section 3 . 2
if an If-None-Match and one of the entity tags listed in it is equal to ;
otherwise.
if an If - None - Match and one of the entity tags listed in it is equal to ; otherwise .
IHttpRequest
this
entityTag
string
The entity tag.
The entity tag .
bool
out
this
The  on which this method is called.
The on which this method is called .
headerExists
When this method returns, a value that indicates whether an
If-None-Match, regardless of the method's
return value. This parameter is passed uninitialized.
When this method returns a value that indicates whether an If - None - Match regardless of the method ' s return value . This parameter is passed uninitialized .
remarks
RFC7232, Section 3.2RFC7232, Section 2.3.2If-None-MatchThe behavior of this method is thus not, strictly speaking, RFC7232-compliant;
it works, though, with entity tags generated by EmbedIO.
RFC7232 Section 3 . 2RFC7232 Section 2 . 3 . 2If - None - MatchThe behavior of this method is thus not strictly speaking RFC7232 - compliant ; it works though with entity tags generated by EmbedIO .