HTTP implementation for Griffin.Networking. It can be used to create HTTP clients and Servers with Griffin.Networking


Keywords
sockets, networking, remoting, http
License
LGPL-3.0
Install
Install-Package Griffin.Networking.Protocol.Http -Version 0.5.2

Documentation

Griffin.Networking

Griffin.Networking has now been superseded by Griffin.Framework. It's pretty much better at everything.

Documentation

Still work in progress but the core framework should be reasonable stable.

Example HTTP listener

internal class Program
{
    public static void RunDemo()
    {
        var server = new MessagingServer(new MyHttpServiceFactory(),
                                            new MessagingServerConfiguration(new HttpMessageFactory()));
        server.Start(new IPEndPoint(IPAddress.Loopback, 8888));
    }
}

// factory
public class MyHttpServiceFactory : IServiceFactory
{
    public IServerService CreateClient(EndPoint remoteEndPoint)
    {
        return new MyHttpService();
    }
}

// and the handler
public class MyHttpService : HttpService
{
    private static readonly BufferSliceStack Stack = new BufferSliceStack(50, 32000);

    public MyHttpService()
        : base(Stack)
    {
    }

    public override void Dispose()
    {
    }

    public override void OnRequest(IRequest request)
    {
        var response = request.CreateResponse(HttpStatusCode.OK, "Welcome");

        response.Body = new MemoryStream();
        response.ContentType = "text/plain";
        var buffer = Encoding.UTF8.GetBytes("Hello world");
        response.Body.Write(buffer, 0, buffer.Length);
        response.Body.Position = 0;

        Send(response);
    }
}