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:
23
Vendor/EmbedIO-3.5.2/Net/Internal/HeaderUtility.cs
vendored
Normal file
23
Vendor/EmbedIO-3.5.2/Net/Internal/HeaderUtility.cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace EmbedIO.Net.Internal
|
||||
{
|
||||
internal static class HeaderUtility
|
||||
{
|
||||
public static string? GetCharset(string? contentType)
|
||||
=> contentType?
|
||||
.Split(';')
|
||||
.Select(p => p.Trim())
|
||||
.Where(part => part.StartsWith("charset", StringComparison.OrdinalIgnoreCase))
|
||||
.Select(GetAttributeValue)
|
||||
.FirstOrDefault();
|
||||
|
||||
public static string? GetAttributeValue(string nameAndValue)
|
||||
{
|
||||
var idx = nameAndValue.IndexOf('=');
|
||||
|
||||
return idx < 0 || idx == nameAndValue.Length - 1 ? null : nameAndValue.Substring(idx + 1).Trim().Unquote();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user