Esempio n. 1
0
        /// <summary>
        /// Handle and process the current Tcp Client connected to the client.
        /// Creates a proxy request and response for the client.
        /// </summary>
        /// <param name="obj">The TcpClient connecting to the proxy server.</param>
        private void ProcessClient(object obj)
        {
            var client = (TcpClient)obj;

            try
            {
                //read the first line HTTP command
                using (var proxyService = new ProxyService(client, _issuerKey))
                    using (this.HttpTracerService)
                    {
                        // generate a proxy request
                        var request = proxyService.ProcessRequest();

                        if (!request.SuccessfulInitializaiton)
                        {
                            return;
                        }

                        // handle response
                        proxyService.ProcessResponse(request);

                        // trace this proxy request
                        this.HttpTracerService.TraceProxyRequest(request);
                    }
            }
            catch (Exception ex)
            {
                //handle exception
                NLogger.Error(ex);
            }
            finally
            {
                client.Close();
            }
        }