[Solved] How do I close the client connection in a uhttpsharp request handler? [closed]


I ended up figuring it out. Since I think it may be useful to others I put it here. Due to how the request handling is implemented the library expects a completed task (available with Task.Factory.GetCompleted) in order to properly close the connection with the client.

    Dim hs As New uhttpsharp.HttpServer(New uhttpsharp.RequestProviders.HttpRequestProvider())
    hs.Use(New uhttpsharp.Listeners.TcpListenerAdapter(New System.Net.Sockets.TcpListener(Net.IPAddress.Any, 12345)))
    hs.Use(Function(context, nxt)
        Dim newBody = $"You asked for: {context.Request.Uri}"
        context.Response = New HttpResponse(HttpResponseCode.Ok, newBody, False)
        Return Task.Factory.GetCompleted()
    End Function)
    hs.Start()
    Console.ReadLine() 
    hs.Dispose()

solved How do I close the client connection in a uhttpsharp request handler? [closed]