This commit is contained in:
2026-06-15 18:18:16 +08:00
parent 97c9fba14e
commit 2b9f134e5f
4164 changed files with 386922 additions and 79 deletions

View File

@@ -0,0 +1,40 @@
using System.Collections.Generic;
namespace Best.HTTP.Shared.Extensions
{
/// <summary>
/// Will parse a comma-separeted header value
/// </summary>
public sealed class HeaderParser : KeyValuePairList
{
public HeaderParser(string headerStr)
{
base.Values = Parse(headerStr);
}
private List<HeaderValue> Parse(string headerStr)
{
List<HeaderValue> result = new List<HeaderValue>();
int pos = 0;
try
{
while (pos < headerStr.Length)
{
HeaderValue current = new HeaderValue();
current.Parse(headerStr, ref pos);
result.Add(current);
}
}
catch(System.Exception ex)
{
HTTPManager.Logger.Exception("HeaderParser - Parse", headerStr, ex);
}
return result;
}
}
}