private async Task <Request> ReadHeaders(PipeReader input) { Request request = null; try { var requestMsg = string.Empty; while ((request = HttpMessageParsing.ParseRequest(requestMsg, false)) == null) { var result = await input.ReadAsync(); foreach (var seg in result.Buffer) { requestMsg += MsgEncoding.GetString(seg.Span); } input.AdvanceTo(result.Buffer.End); } } catch (Exception ex) { Console.WriteLine($"{ex.GetType()}: {ex.Message}"); } return(request); }
private async Task <Request> ReadBody(Request request, PipeReader input) { var msg = request.HeaderText; try { while ((request = HttpMessageParsing.ParseRequest(msg, true)) == null) { var result = await input.ReadAsync(); foreach (var seg in result.Buffer) { msg += MsgEncoding.GetString(seg.Span); } input.AdvanceTo(result.Buffer.End); } } catch (Exception ex) { Console.WriteLine($"{ex.GetType()}: {ex.Message}"); } return(request); }