Beispiel #1
0
        public Http(ConnectionHandler handler)
        {
            TcpConnection = handler.Client;

            this.Request = new Request.Request(new BufferedStream(handler.InputStream));
            this.Response = new Response.Response(new BufferedStream(TcpConnection.GetStream()));

            Current = this;
        }
        public async Task ConnectionAvailable(ConnectionHandler handler)
        {
            currentConnection = handler;

            Log.Trace("Creating new http context");
            var http = new Http(currentConnection);

            Log.Trace("Start http processing");
            using (new Stopper(x => Log.Trace($"HTTP processing time: {x.ElapsedMilliseconds}ms")))
            {
                await http.Process();
            }
            Log.Trace("End http processing");
        }
Beispiel #3
0
        private async void HandleAsync(TcpClient client)
        {
            await Task.Run(async () =>
            {
                var jobs = Interlocked.Increment(ref currentJobs);
                Log.Trace($"Current jobs (BEFORE): {jobs}");

                var handler = new ConnectionHandler(client);
                using (new Stopper(x => Log.Trace($"Processing time: {x.ElapsedMilliseconds}ms")))
                {
                    await handler.TryAsync(h => h.HandleClient(), (connectionHandler, exception) =>
                    {
                        Log.Error(exception, "Error processing client request");
                    });
                }

                jobs = Interlocked.Decrement(ref currentJobs);
                Log.Trace($"Current jobs (AFTER): {jobs}");
            });
        }