src/packages/EmbedIO/Utilities/Validate-Rfc2616.cs
/// <summary>
/// <para>Ensures that a <see langword="string"/> argument is valid as a token as defined by
/// <see href="https://tools.ietf.org/html/rfc2616#section-2.2">RFC2616, Section 2.2</see>.</para>
/// <para>RFC2616 tokens are used, for example, as:</para>
/// <list type="bullet">
/// <item><description>cookie names, as stated in <see href="https://tools.ietf.org/html/rfc6265#section-4.1.1">RFC6265, Section 4.1.1</see>;</description></item>
/// <item><description>WebSocket protocol names, as stated in <see href="https://tools.ietf.org/html/rfc6455#section-4.3">RFC6455, Section 4.3</see>.</description></item>
/// </list>
/// <para>Only a restricted set of characters are allowed in tokens, including:</para>
/// <list type="bullet">
/// <item><description>upper- and lower-case letters of the English alphabet;</description></item>
/// <item><description>decimal digits;</description></item>
/// <item><description>the following non-alphanumeric characters:
/// <c>!</c>, <c>#</c>, <c>$</c>, <c>%</c>, <c>&amp;</c>, <c>'</c>, <c>*</c>, <c>+</c>,
/// <c>-</c>, <c>.</c>, <c>^</c>, <c>_</c>, <c>`</c>, <c>|</c>, <c>~</c>.</description></item>
/// </list>
/// </summary>
/// <param name="argumentName">The name of the argument to validate.</param>
/// <param name="value">The value to validate.</param>
/// <param name="entity">What is being validated. This string is put at the start of the exception
/// message when validation fails. Default is <c>"Token"</c>, as in <c>"Token contains one or more invalid characters."</c></param>
/// <returns><paramref name="value"/>, if it is a valid token.</returns>
/// <exception cref="ArgumentNullException"><paramref name="value"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="value"/> is the empty string.</para>
/// <para>- or -</para>
/// <para><paramref name="value"/> contains one or more characters that are not allowed in a token.</para>
/// </exception>
Ensures that a  argument is valid as a token as defined by
RFC2616, Section 2.2RFC2616 tokens are used, for example, as:cookie names, as stated in RFC6265, Section 4.1.1WebSocket protocol names, as stated in RFC6455, Section 4.3Only a restricted set of characters are allowed in tokens, including:upper- and lower-case letters of the English alphabet;decimal digits;the following non-alphanumeric characters:
#$%&'*+-.^_`|~
Ensures that a argument is valid as a token as defined by RFC2616 Section 2 . 2RFC2616 tokens are used for example as : cookie names as stated in RFC6265 Section 4 . 1 . 1WebSocket protocol names as stated in RFC6455 Section 4 . 3Only a restricted set of characters are allowed in tokens including : upper - and lower - case letters of the English alphabet ; decimal digits ; the following non - alphanumeric characters : #$%& ' * + - . ^_ ` |~
public static string Rfc2616Token(string argumentName, [ValidatedNotNull] string value, string entity = "Token")
        {
            value = NotNullOrEmpty(argumentName, value);
            if (!IsRfc2616Token(value))
                throw new ArgumentException(entity + " contains one or more invalid characters.", argumentName);
            return value;
        }
public static string Rfc2616Token ( string argumentName , [ ValidatedNotNull ] string value , string entity = " " ) { value = NotNullOrEmpty ( argumentName , value ) ; if ( ! IsRfc2616Token ( value ) ) throw new ArgumentException ( entity + " " , argumentName ) ; return value ; }
Ensures that a  argument is valid as a token as defined by
RFC2616, Section 2.2RFC2616 tokens are used, for example, as:cookie names, as stated in RFC6265, Section 4.1.1WebSocket protocol names, as stated in RFC6455, Section 4.3Only a restricted set of characters are allowed in tokens, including:upper- and lower-case letters of the English alphabet;decimal digits;the following non-alphanumeric characters:
#$%&'*+-.^_`|~
Ensures that a argument is valid as a token as defined by RFC2616 Section 2 . 2RFC2616 tokens are used for example as : cookie names as stated in RFC6265 Section 4 . 1 . 1WebSocket protocol names as stated in RFC6455 Section 4 . 3Only a restricted set of characters are allowed in tokens including : upper - and lower - case letters of the English alphabet ; decimal digits ; the following non - alphanumeric characters : #$%& ' * + - . ^_ ` |~
, if it is a valid token.
if it is a valid token .
None
None
argumentName
string
The name of the argument to validate.
The name of the argument to validate .
string
[ValidatedNotNull]
entity
string
None
value
The value to validate.
The value to validate .