public static void ValidateHeaderCharacters(string headerCharacters) { if (headerCharacters != null) { var invalid = HttpCharacters.IndexOfInvalidFieldValueCharExtended(headerCharacters); if (invalid >= 0) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Invalid control character in header: 0x{0:X2}", headerCharacters[invalid])); } } }
public static void ValidateHeaderValueCharacters(string headerCharacters, bool requireAscii) { if (headerCharacters != null) { var invalid = requireAscii ? HttpCharacters.IndexOfInvalidFieldValueChar(headerCharacters) : HttpCharacters.IndexOfInvalidFieldValueCharExtended(headerCharacters); if (invalid >= 0) { ThrowInvalidHeaderCharacter(headerCharacters[invalid]); } } }