public void Parse_InvalidValue_Throw() { // This test verifies that Parse() correctly calls TryParse(). HttpHeaderParser parser = GenericHeaderParser.MultipleValueNameValueWithParametersParser; int index = 0; Assert.Throws <FormatException>(() => { parser.ParseValue("custom;=value", null, ref index); }); }
public void Parse_ValidValue_ReturnsNameValueWithParametersHeaderValue() { // This test verifies that Parse() correctly calls TryParse(). HttpHeaderParser parser = GenericHeaderParser.MultipleValueNameValueWithParametersParser; int index = 2; NameValueWithParametersHeaderValue expected = new NameValueWithParametersHeaderValue("custom"); expected.Parameters.Add(new NameValueHeaderValue("name", "value")); Assert.True(expected.Equals(parser.ParseValue(" custom ; name = value ", null, ref index))); Assert.Equal(25, index); }
/// <summary> /// Parses <paramref name="input"/> as a <see cref="CacheControlHeaderValue"/> value. /// </summary> /// <param name="input">The values to parse.</param> /// <returns>The parsed values.</returns> public static CacheControlHeaderValue Parse(StringSegment input) { var index = 0; // Cache-Control is unusual because there are no required values so the parser will succeed for an empty string, but still return null. var result = Parser.ParseValue(input, ref index); if (result == null) { throw new FormatException("No cache directives found."); } return(result); }
/// <summary> /// Parses <paramref name="input"/> as a <see cref="RangeConditionHeaderValue"/> value. /// </summary> /// <param name="input">The values to parse.</param> /// <returns>The parsed values.</returns> public static RangeConditionHeaderValue Parse(StringSegment input) { var index = 0; return(Parser.ParseValue(input, ref index) !); }
/// <summary> /// Parses <paramref name="input"/> as a <see cref="ContentDispositionHeaderValue"/> value. /// </summary> /// <param name="input">The values to parse.</param> /// <returns>The parsed values.</returns> public static ContentDispositionHeaderValue Parse(StringSegment input) { var index = 0; return(Parser.ParseValue(input, ref index) !); }
/// <summary> /// Parses the specified <paramref name="input"/> as a <see cref="StringWithQualityHeaderValue"/>. /// </summary> /// <param name="input">The value to parse.</param> /// <returns>The parsed value.</returns> public static StringWithQualityHeaderValue Parse(StringSegment input) { var index = 0; return(SingleValueParser.ParseValue(input, ref index) !); }
/// <summary> /// Parses <paramref name="input"/> as a <see cref="EntityTagHeaderValue"/> value. /// </summary> /// <param name="input">The values to parse.</param> /// <returns>The parsed values.</returns> public static EntityTagHeaderValue Parse(StringSegment input) { var index = 0; return(SingleValueParser.ParseValue(input, ref index) !); }
public static SetCookieHeaderValue Parse(string input) { var index = 0; return(SingleValueParser.ParseValue(input, ref index)); }
public static NameValueHeaderValue Parse(StringSegment input) { var index = 0; return(SingleValueParser.ParseValue(input, ref index)); }