Beispiel #1
0
 private void init()
 {
     this._chunked       = false;
     this._context       = new HttpListenerContext(this);
     this._inputState    = HttpConnection.InputState.RequestLine;
     this._inputStream   = null;
     this._lineState     = HttpConnection.LineState.None;
     this._outputStream  = null;
     this._position      = 0;
     this._prefix        = null;
     this._requestBuffer = new MemoryStream();
 }
Beispiel #2
0
 private void Init()
 {
     this.context_bound = false;
     this.i_stream      = null;
     this.o_stream      = null;
     this.prefix        = null;
     this.chunked       = false;
     this.ms            = new MemoryStream();
     this.position      = 0;
     this.input_state   = HttpConnection.InputState.RequestLine;
     this.line_state    = HttpConnection.LineState.None;
     this.context       = new HttpListenerContext(this);
 }
Beispiel #3
0
        private bool processInput(byte[] data)
        {
            int num  = data.Length;
            int num2 = 0;

            try
            {
                string text;
                while ((text = this.readLine(data, this._position, num - this._position, ref num2)) != null)
                {
                    this._position += num2;
                    if (text.Length == 0)
                    {
                        if (this._inputState != HttpConnection.InputState.RequestLine)
                        {
                            this._currentLine = null;
                            return(true);
                        }
                    }
                    else
                    {
                        if (this._inputState == HttpConnection.InputState.RequestLine)
                        {
                            this._context.Request.SetRequestLine(text);
                            this._inputState = HttpConnection.InputState.Headers;
                        }
                        else
                        {
                            this._context.Request.AddHeader(text);
                        }
                        if (this._context.HaveError)
                        {
                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this._context.ErrorMessage = ex.Message;
                return(true);
            }
            this._position += num2;
            if (num2 == num)
            {
                this._requestBuffer.SetLength(0L);
                this._position = 0;
            }
            return(false);
        }
Beispiel #4
0
        private bool ProcessInput(MemoryStream ms)
        {
            byte[] array = ms.GetBuffer();
            int    num   = (int)ms.Length;
            int    num2  = 0;
            string text;

            try
            {
                text           = this.ReadLine(array, this.position, num - this.position, ref num2);
                this.position += num2;
            }
            catch (Exception ex)
            {
                this.context.ErrorMessage = "Bad request";
                this.context.ErrorStatus  = 400;
                return(true);
            }
            while (text != null)
            {
                if (text == string.Empty)
                {
                    if (this.input_state != HttpConnection.InputState.RequestLine)
                    {
                        this.current_line = null;
                        ms = null;
                        return(true);
                    }
                }
                else
                {
                    if (this.input_state == HttpConnection.InputState.RequestLine)
                    {
                        this.context.Request.SetRequestLine(text);
                        this.input_state = HttpConnection.InputState.Headers;
                    }
                    else
                    {
                        try
                        {
                            this.context.Request.AddHeader(text);
                        }
                        catch (Exception ex2)
                        {
                            this.context.ErrorMessage = ex2.Message;
                            this.context.ErrorStatus  = 400;
                            return(true);
                        }
                    }
                    if (this.context.HaveError)
                    {
                        return(true);
                    }
                    if (this.position >= num)
                    {
                        break;
                    }
                    try
                    {
                        text           = this.ReadLine(array, this.position, num - this.position, ref num2);
                        this.position += num2;
                    }
                    catch (Exception ex3)
                    {
                        this.context.ErrorMessage = "Bad request";
                        this.context.ErrorStatus  = 400;
                        return(true);
                    }
                }
                if (text != null)
                {
                    continue;
                }
IL_194:
                if (num2 == num)
                {
                    ms.SetLength(0L);
                    this.position = 0;
                }
                return(false);
            }
            goto IL_194;
        }