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