Got at least one data fetching method working; turns out, we can't use a patched LogicStack to get the data

This commit is contained in:
2026-01-14 22:11:11 +01:00
parent 40a8431464
commit 3f7122d30a
350 changed files with 41444 additions and 119 deletions

View File

@@ -0,0 +1,77 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EmbedIO.Net.Internal
{
internal static class StringExtensions
{
private const string TokenSpecialChars = "()<>@,;:\\\"/[]?={} \t";
internal static bool IsToken(this string @this)
=> @this.All(c => c >= 0x20 && c < 0x7f && TokenSpecialChars.IndexOf(c) < 0);
internal static IEnumerable<string> SplitHeaderValue(this string @this, bool useCookieSeparators)
{
var len = @this.Length;
var buff = new StringBuilder(32);
var escaped = false;
var quoted = false;
for (var i = 0; i < len; i++)
{
var c = @this[i];
if (c == '"')
{
if (escaped)
{
escaped = false;
}
else
{
quoted = !quoted;
}
}
else if (c == '\\')
{
if (i < len - 1 && @this[i + 1] == '"')
{
escaped = true;
}
}
else if (c == ',' || (useCookieSeparators && c == ';'))
{
if (!quoted)
{
yield return buff.ToString();
buff.Length = 0;
continue;
}
}
_ = buff.Append(c);
}
if (buff.Length > 0)
{
yield return buff.ToString();
}
}
internal static string Unquote(this string str)
{
var start = str.IndexOf('\"');
var end = str.LastIndexOf('\"');
if (start >= 0 && end >= 0)
{
str = str.Substring(start + 1, end - 1);
}
return str.Trim();
}
}
}