static void SetHeader(HttpHeaderDictionary headers, string fieldName, IEnumerable <string> fieldValues) { if (HttpHeaderClassification.IsHopByHopHeader(fieldName)) { return; } if (HttpHeaderClassification.IsAppendedOnForwardHeader(fieldName)) { headers.AddValues(fieldName, fieldValues); } else { headers.Remove(fieldName); headers.AddValues(fieldName, fieldValues); } }
public void remove_through_kvp_in_multi_values() { headers.Add("key", "value0"); headers.AddValues("key", new[] { "value1", "value2" }); headers.Add("key", "value3"); headers.Remove(new KeyValuePair <string, string>("key", "value2")).ShouldBeTrue(); headers.ShouldHaveHeaderValues("key", "value0", "value1", "value3"); }