public void SetAndEscapeValue(StringSegment value)
 {
     HeaderUtilities.ThrowIfReadOnly(IsReadOnly);
     if (StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length))
     {
         _value = value;
     }
     else
     {
         Value = HeaderUtilities.EscapeAsQuotedString(value);
     }
 }
示例#2
0
 public StringSegment EscapeAsQuotedString()
 {
     return(HeaderUtilities.EscapeAsQuotedString("\"hello\\\"foo\\\\bar\\\\baz\\\\\""));
 }
示例#3
0
 public void SetAndEscapeValue_ControlCharactersThrowFormatException(string input)
 {
     Assert.Throws <FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString(input); });
 }
示例#4
0
 public void SetAndEscapeValue_ThrowsFormatExceptionOnDelCharacter()
 {
     Assert.Throws <FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString($"{(char)0x7F}"); });
 }
示例#5
0
        public void SetAndEscapeValue_BehaviorCheck(string input, string expected)
        {
            var actual = HeaderUtilities.EscapeAsQuotedString(input);

            Assert.Equal(expected, actual);
        }