Beispiel #1
0
 public Response(StatusLine statusLine, HttpHeaders headers, byte[] body = null)
 {
     StatusLine = statusLine;
     Headers    = headers ?? new HttpHeaders();
     if (body != null)
     {
         Body = body;
     }
 }
 public async Task BuildAndReturnResponseAsync(ProtocolVersion version, HttpStatusCode code, string description, string body = null, bool closeConnection = false)
 {
     using (_session.Logger.Enter("Creating ??"))
     {
         var statusLine = new StatusLine(version, code, description);
         _session.Logger.Info($"Responding with [{statusLine}]");
         var response = new Response(
             statusLine,
             new HttpHeaders
         {
             { "Date", DateTime.UtcNow.ToString("r") },
             { "Timestamp", DateTime.UtcNow.ToString("HH:mm:ss.fff") }
         });
         if (body != null)
         {
             response.Body = response.BodyEncoding.GetBytes(body);
         }
         await ReturnResponseAsync(response, closeConnection).WithoutCapturingContext();
     }
 }
 public async Task WriteStatusLineAsync(StatusLine statusLine)
 {
     await WriteLineAsync(statusLine.ToString()).WithoutCapturingContext();
 }
        public async Task <StatusLine> ReadStatusLineAsync()
        {
            var line = await ReadLineAsync();

            return(line == null ? null : StatusLine.Parse(line));
        }