Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 59b44a4

Browse files
committed
Move *CommaSeperatedValues APIs from IHeaderDictionary to extension.
1 parent 456277f commit 59b44a4

File tree

5 files changed

+670
-150
lines changed

5 files changed

+670
-150
lines changed

src/Microsoft.AspNet.Http.Abstractions/IHeaderDictionary.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,5 @@ public interface IHeaderDictionary : IReadableStringCollection, IDictionary<stri
3030
/// Gets a collection containing the keys.
3131
/// </summary>
3232
new ICollection<string> Keys { get; }
33-
34-
/// <summary>
35-
/// Get the associated values from the collection separated into individual values.
36-
/// Quoted values will not be split, and the quotes will be removed.
37-
/// </summary>
38-
/// <param name="key">The header name.</param>
39-
/// <returns>the associated values from the collection separated into individual values, or null if the key is not present.</returns>
40-
StringValues GetCommaSeparatedValues(string key);
41-
42-
/// <summary>
43-
/// Add a new value. Appends to the header list if already present
44-
/// </summary>
45-
/// <param name="key">The header name.</param>
46-
/// <param name="value">The header value.</param>
47-
void Append(string key, StringValues value);
48-
49-
/// <summary>
50-
/// Quotes any values containing comas, and then coma joins all of the values with any existing values.
51-
/// </summary>
52-
/// <param name="key">The header name.</param>
53-
/// <param name="values">The header values.</param>
54-
void AppendCommaSeparatedValues(string key, params string[] values);
55-
56-
/// <summary>
57-
/// Quotes any values containing comas, and then coma joins all of the values.
58-
/// </summary>
59-
/// <param name="key">The header name.</param>
60-
/// <param name="values">The header values.</param>
61-
void SetCommaSeparatedValues(string key, params string[] values);
6233
}
6334
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.AspNet.Http.Internal;
5+
using Microsoft.Framework.Primitives;
6+
7+
namespace Microsoft.AspNet.Http
8+
{
9+
public static class HeaderDictionaryExtensions
10+
{
11+
/// <summary>
12+
/// Add new values. Each item remains a separate array entry.
13+
/// </summary>
14+
/// <param name="key">The header name.</param>
15+
/// <param name="value">The header value.</param>
16+
public static void Append(this IHeaderDictionary headers, string key, StringValues value)
17+
{
18+
ParsingHelpers.AppendHeaderUnmodified(headers, key, value);
19+
}
20+
21+
/// <summary>
22+
/// Quotes any values containing comas, and then coma joins all of the values with any existing values.
23+
/// </summary>
24+
/// <param name="key">The header name.</param>
25+
/// <param name="values">The header values.</param>
26+
public static void AppendCommaSeparatedValues(this IHeaderDictionary headers, string key, params string[] values)
27+
{
28+
ParsingHelpers.AppendHeaderJoined(headers, key, values);
29+
}
30+
31+
/// <summary>
32+
/// Get the associated values from the collection separated into individual values.
33+
/// Quoted values will not be split, and the quotes will be removed.
34+
/// </summary>
35+
/// <param name="key">The header name.</param>
36+
/// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
37+
public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
38+
{
39+
return ParsingHelpers.GetHeaderSplit(headers, key);
40+
}
41+
42+
/// <summary>
43+
/// Quotes any values containing comas, and then coma joins all of the values.
44+
/// </summary>
45+
/// <param name="key">The header name.</param>
46+
/// <param name="values">The header values.</param>
47+
public static void SetCommaSeparatedValues(this IHeaderDictionary headers, string key, params string[] values)
48+
{
49+
ParsingHelpers.SetHeaderJoined(headers, key, values);
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)