Esempio n. 1
0
 // Token: 0x0600090C RID: 2316 RVA: 0x0001E8EC File Offset: 0x0001CAEC
 protected override void ProcessSend(SocketAsyncEventArgs e)
 {
     if (!base.ValidateAsyncResult(e))
     {
         return;
     }
     HttpConnectProxy.ConnectContext connectContext = (HttpConnectProxy.ConnectContext)e.UserToken;
     byte[] array = new byte[this.m_ReceiveBufferSize];
     e.SetBuffer(array, 0, array.Length);
     this.StartReceive(connectContext.Socket, e);
 }
Esempio n. 2
0
        // Token: 0x0600090D RID: 2317 RVA: 0x0001E934 File Offset: 0x0001CB34
        protected override void ProcessReceive(SocketAsyncEventArgs e)
        {
            if (!base.ValidateAsyncResult(e))
            {
                return;
            }
            HttpConnectProxy.ConnectContext connectContext = (HttpConnectProxy.ConnectContext)e.UserToken;
            int matched = connectContext.SearchState.Matched;
            int num     = e.Buffer.SearchMark(e.Offset, e.BytesTransferred, connectContext.SearchState);

            if (num < 0)
            {
                int num2 = e.Offset + e.BytesTransferred;
                if (num2 >= this.m_ReceiveBufferSize)
                {
                    base.OnException("receive buffer size has been exceeded");
                    return;
                }
                e.SetBuffer(num2, this.m_ReceiveBufferSize - num2);
                this.StartReceive(connectContext.Socket, e);
                return;
            }
            else
            {
                int num3 = (matched > 0) ? (e.Offset - matched) : (e.Offset + num);
                if (e.Offset + e.BytesTransferred > num3 + HttpConnectProxy.m_LineSeparator.Length)
                {
                    base.OnException("protocol error: more data has been received");
                    return;
                }
                string text = new StringReader(ProxyConnectorBase.ASCIIEncoding.GetString(e.Buffer, 0, num3)).ReadLine();
                if (string.IsNullOrEmpty(text))
                {
                    base.OnException("protocol error: invalid response");
                    return;
                }
                int num4 = text.IndexOf(' ');
                if (num4 <= 0 || text.Length <= num4 + 2)
                {
                    base.OnException("protocol error: invalid response");
                    return;
                }
                string value = text.Substring(0, num4);
                if (!"HTTP/1.1".Equals(value))
                {
                    base.OnException("protocol error: invalid protocol");
                    return;
                }
                int num5 = text.IndexOf(' ', num4 + 1);
                if (num5 < 0)
                {
                    base.OnException("protocol error: invalid response");
                    return;
                }
                int num6;
                if (!int.TryParse(text.Substring(num4 + 1, num5 - num4 - 1), out num6) || num6 > 299 || num6 < 200)
                {
                    base.OnException("the proxy server refused the connection");
                    return;
                }
                base.OnCompleted(new ProxyEventArgs(connectContext.Socket, base.TargetHostHame));
                return;
            }
        }