コード例 #1
0
        public static bool TryParseRequestUri(ByteSpan buffer, out Utf8Span requestUri, out int parsedBytes)
        {
            var uriSpan = HttpReader.SliceTo(buffer, HttpReader.s_SP, out parsedBytes);

            requestUri = new Utf8Span(uriSpan);
            return(parsedBytes != 0);
        }
コード例 #2
0
        public static bool TryParseHttpVersion(ByteSpan buffer, out Utf8Span httpVersion, out int parsedBytes)
        {
            var versionSpan = HttpReader.SliceTo(buffer, HttpReader.s_CR, HttpReader.s_LF, out parsedBytes);

            httpVersion = new Utf8Span(versionSpan);
            return(parsedBytes != 0);
        }
コード例 #3
0
        public static bool TryParseRequestLine(ByteSpan buffer, out HttpRequestLine requestLine, out int totalParsedBytes)
        {
            requestLine      = new HttpRequestLine();
            totalParsedBytes = 0;

            var reader = new HttpReader();

            reader.Buffer = buffer;

            requestLine.Method = reader.ReadMethod();
            if (requestLine.Method == HttpMethod.Unknown)
            {
                return(false);
            }

            requestLine.RequestUri = reader.ReadRequestUri();
            if (requestLine.RequestUri.Length == 0)
            {
                return(false);
            }

            requestLine.Version = reader.ReadHttpVersion();
            if (requestLine.Version == HttpVersion.Unknown)
            {
                return(false);
            }

            totalParsedBytes = buffer.Length - reader.Buffer.Length;
            return(true);
        }
コード例 #4
0
ファイル: HttpReader.cs プロジェクト: GrimDerp/corefxlab
        public static bool TryParseRequestLine(ByteSpan buffer, out HttpRequestLine requestLine, out int totalParsedBytes)
        {
            requestLine = new HttpRequestLine();
            totalParsedBytes = 0;

            var reader = new HttpReader();
            reader.Buffer = buffer;

            requestLine.Method = reader.ReadMethod();
            if(requestLine.Method == HttpMethod.Unknown) { return false; }

            requestLine.RequestUri = reader.ReadRequestUri();
            if(requestLine.RequestUri.Length == 0) { return false; }

            requestLine.Version = reader.ReadHttpVersion();
            if (requestLine.Version == HttpVersion.Unknown) { return false; }

            totalParsedBytes = buffer.Length - reader.Buffer.Length;
            return true;
        }