Esempio n. 1
0
            private void RspHttpHandshakeReceive()
            {
                if (_httpProxyState == null)
                {
                    _httpProxyState = new HttpParser(true);
                }
                _httpProxyState.httpAuthUser = _config.AuthUser;
                _httpProxyState.httpAuthPass = _config.AuthPass;
                var err = _httpProxyState.HandshakeReceive(_firstPacket, _firstPacketLength, out _);

                if (err == 1)
                {
                    _local.BeginReceive(_connetionRecvBuffer, 0, _firstPacket.Length, 0,
                                        HttpHandshakeRecv, null);
                }
                else if (err == 2)
                {
                    var dataSend = HttpParser.Http407();
                    var httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
                    _local.BeginSend(httpData, 0, httpData.Length, 0, HttpHandshakeAuthEndSend, null);
                }
                else if (err == 3)
                {
                    Connect();
                }
                else if (err == 4)
                {
                    Connect();
                }
                else if (err == 0)
                {
                    var dataSend = HttpParser.Http200();
                    var httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
                    _local.BeginSend(httpData, 0, httpData.Length, 0, StartConnect, null);
                }
                else if (err == 500)
                {
                    var dataSend = HttpParser.Http500();
                    var httpData = System.Text.Encoding.UTF8.GetBytes(dataSend);
                    _local.BeginSend(httpData, 0, httpData.Length, 0, HttpHandshakeAuthEndSend, null);
                }
            }