Пример #1
0
 public HttpProxySession(Socket socket)
 {
     cTcpClient            = new HHTcpClient(socket);
     Handle                = socket.Handle;
     cTcpClient.OnError   += OnError;
     cTcpClient.OnReceive += OnReceive;
     cTcpClient.OnSendEnd += OnSendEnd;
     HttpProxySessionInfo  = new HttpProxySessionInfo();
     ReceiveBufferSize     = socket.ReceiveBufferSize;
 }
Пример #2
0
        private static void OnPorxyOver(HttpProxySessionInfo httpProxySessionInfo, ClientErrorType errorType)
        {
            string msg = $"本次代理结束:{httpProxySessionInfo.HttpRequestType} {httpProxySessionInfo.HttpPath} {httpProxySessionInfo.HttpVersion} {Environment.NewLine}"
                         + $"Host: {httpProxySessionInfo.Host} {Environment.NewLine}"
                         + $"Port: {httpProxySessionInfo.Port} {Environment.NewLine}"
                         + $"累计转发到目的地: {httpProxySessionInfo.AllSendLength} {Environment.NewLine}"
                         + $"累计转发到客户端: {httpProxySessionInfo.AllRetLength} {Environment.NewLine}"
                         + $"结束原因: {errorType.ToString()} {Environment.NewLine}"
                         + $"持续时间: {(httpProxySessionInfo.LastActionTime - httpProxySessionInfo.ConnectTime).TotalMilliseconds}ms {Environment.NewLine}"
                         + $"当前时间: {DateTime.Now.ToLocalTime().ToString()} {Environment.NewLine}"
                         + $"连接时间: {httpProxySessionInfo.ConnectTime.ToLocalTime().ToString()} {Environment.NewLine}"
                         + $"最后连接时间: {httpProxySessionInfo.LastActionTime.ToLocalTime().ToString()} {Environment.NewLine}";

            Console.WriteLine(msg);
        }