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); }
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); }
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); }
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; }