shoko/Protocols/ResProtoHandler.cs

34 lines
687 B
C#
Raw Normal View History

using System.Reflection;
using System.Web;
2023-10-09 02:27:47 +00:00
using HeyRed.Mime;
namespace Shoko;
[Protocol("res")]
class ResProtoHandler : ProtoHandler
{
public ResProtoHandler(Uri url)
{
URL = url;
}
public override void Load()
{
var path = HttpUtility.HtmlDecode(new UriBuilder(URL).Path);
Status = "OK";
Loaded = true;
try
{
Content = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
2023-10-09 02:27:47 +00:00
MediaType = MimeGuesser.GuessMimeType(Content);
}
catch
{
Status = "not found";
Loaded = false;
}
}
public override void Render()
{
}
}