Esempio n. 1
0
 /// <summary>
 /// Sets <see cref="Value"/> after it has been quoted as defined by <see href="https://tools.ietf.org/html/rfc7230#section-3.2.6">the RFC specification</see>.
 /// </summary>
 /// <param name="value"></param>
 public void SetAndEscapeValue(StringSegment value)
 {
     HeaderUtilities.ThrowIfReadOnly(IsReadOnly);
     if (StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length))
     {
         _value = value;
     }
     else
     {
         Value = HeaderUtilities.EscapeAsQuotedString(value);
     }
 }
Esempio n. 2
0
 public void SetAndEscapeValue_ThrowsFormatExceptionOnDelCharacter()
 {
     Assert.Throws <FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString($"{(char)0x7F}"); });
 }
Esempio n. 3
0
    public void SetAndEscapeValue_BehaviorCheck(string input, string expected)
    {
        var actual = HeaderUtilities.EscapeAsQuotedString(input);

        Assert.Equal(expected, actual);
    }
Esempio n. 4
0
 public void SetAndEscapeValue_ControlCharactersThrowFormatException(string input)
 {
     Assert.Throws <FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString(input); });
 }
 public StringSegment EscapeAsQuotedString()
 {
     return(HeaderUtilities.EscapeAsQuotedString("\"hello\\\"foo\\\\bar\\\\baz\\\\\""));
 }