示例#1
0
        public static HttpRequestSingleSegment Parse(ReadOnlySpan <byte> bytes)
        {
            int parsed = HttpRequestParser.TryParseRequestLine(bytes, out var requestLine);

            if (parsed == 0)
            {
                throw new NotImplementedException("request line parser");
            }

            bytes = bytes.Slice(parsed);

            parsed = HttpRequestParser.TryParseHeaders(bytes, out var headers);
            if (parsed == 0)
            {
                throw new NotImplementedException("headers parser");
            }

            var body    = bytes.Slice(parsed);
            var request = new HttpRequestSingleSegment(requestLine, headers, body);

            return(request);
        }