Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void AppendCommaSeparatedValues(this IHeaderDictionary headers, st
/// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
{
return ParsingHelpers.GetHeaderSplit(headers, key).ToArray();
return ParsingHelpers.GetHeaderSplit(headers, key);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static void AppendHeaderUnmodified(IHeaderDictionary headers, string key,
throw new ArgumentNullException(nameof(key));
}

if (values.Count == 0)
if (values.IsNull)
{
return;
}
Expand Down
16 changes: 11 additions & 5 deletions src/Microsoft.AspNetCore.Http/HeaderDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public StringValues this[string key]
}
ThrowIfReadOnly();

if (StringValues.IsNullOrEmpty(value))
if (value.ToString().Length == 0)
{
Store?.Remove(key);
}
Expand Down Expand Up @@ -177,8 +177,11 @@ public void Add(KeyValuePair<string, StringValues> item)
throw new ArgumentNullException("The key is null");
}
ThrowIfReadOnly();
EnsureStore(1);
Store.Add(item.Key, item.Value);
if (item.Value.ToString().Length > 0)
{
EnsureStore(1);
Store.Add(item.Key, item.Value);
}
}

/// <summary>
Expand All @@ -193,8 +196,11 @@ public void Add(string key, StringValues value)
throw new ArgumentNullException(nameof(key));
}
ThrowIfReadOnly();
EnsureStore(1);
Store.Add(key, value);
if (value.ToString().Length > 0)
{
EnsureStore(1);
Store.Add(key, value);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Append(string key, string value)
StringValues values;
if (_accumulator.TryGetValue(key, out values))
{
if (values.Count == 0)
if (values.IsNull)
{
// Marker entry for this key to indicate entry already in expanding list dictionary
_expandingAccumulator[key].Add(value);
Expand Down