private static void AddHeaderValues(WebHeaderCollection source, int index, string header, HttpHeaders destination) { string[] values = source.GetValues(index); // Even though AddWithoutValidation() could throw FormatException for header values containing newline // chars that are not followed by whitespace chars, we don't need to catch that exception. Our header // values were returned by HttpWebResponse which is trusted to only return valid header values. if (values.Length == 1) { destination.AddWithoutValidation(header, values[0]); } else { for (int j = 0; j < values.Length; j++) { destination.AddWithoutValidation(header, values[j]); } } }
public static bool TryAddWithoutValidation(this HttpHeaders headers, string key, IEnumerable <string> values) { headers.AddWithoutValidation(key, values); return(true); }
public static void TryAddWithoutValidation(this HttpHeaders headers, string key, string value) { headers.AddWithoutValidation(key, value); }