shoko/Protocols/FingerProtoHandler.cs

37 lines
708 B
C#
Raw Normal View History

using System.Net.Sockets;
using System.Text;
using System.Web;
namespace Shoko;
[Protocol("finger")]
class FingerProtoHandler : ProtoHandler
{
public FingerProtoHandler(Uri url)
{
URL = url;
}
public override void Load()
{
var file = URL.PathAndQuery;
if(file.StartsWith("/")) file = file.Remove(0,1);
var uri = Encoding.UTF8.GetBytes(HttpUtility.UrlDecode(file)+"\r\n");
var tcp = new TcpClient(URL.Host, URL.Port < 0 ? 79 : URL.Port);
var stream = tcp.GetStream();
stream.Write(uri);
Content = stream;
MediaType = "text/plain";
Loaded = true;
}
public override void Render()
{
}
}