HitProxy.Http.Request.ParseFirstLine C# (CSharp) Method

ParseFirstLine() protected method

protected ParseFirstLine ( string firstLine ) : void
firstLine string
return void
        protected override void ParseFirstLine(string firstLine)
        {
            if (firstLine == null)
                throw new HeaderException ("No data", HttpStatusCode.BadRequest);
            //Console.Error.WriteLine ("First: " + firstLine);
            string[] parts = firstLine.Split (' ');
            if (parts.Length != 3)
                throw new HeaderException ("Invalid header: " + firstLine, HttpStatusCode.BadRequest);

            Method = parts [0].ToUpperInvariant ();
            HttpVersion = parts [2];
            if (parts [1] [0] == '/') {
                if (System.Uri.TryCreate (parts [1], UriKind.Relative, out this.Uri))
                    return;
            } else {
                if (System.Uri.TryCreate (parts [1], UriKind.Absolute, out this.Uri))
                    return;
                if (System.Uri.TryCreate ("http://" + parts [1], UriKind.Absolute, out this.Uri))
                    return;
            }
            Console.Error.WriteLine ("Invalid URL: " + parts [1]);
            throw new HeaderException ("Invalid URL", HttpStatusCode.BadRequest);
        }