Exemplo n.º 1
0
        public void CopyTo(bool chunk, WritableChannelFormatter outputFormatter)
        {
            foreach (var header in _headers)
            {
                outputFormatter.Write(_headersStartBytes);
                outputFormatter.Append(header.Key);
                outputFormatter.Write(_headersSeperatorBytes);
                outputFormatter.Append(header.Value.ToString());
            }

            if (chunk)
            {
                outputFormatter.Write(_chunkedHeaderBytes);
            }

            outputFormatter.Write(_serverHeaderBytes);
            var date = _dateHeaderValueManager.GetDateHeaderValues().Bytes;

            outputFormatter.Write(date);

            outputFormatter.Write(_headersEndBytes);
        }
Exemplo n.º 2
0
        public Task WriteAsync(Span<byte> data)
        {
            if (!HasStarted)
            {
                WriteBeginResponseHeaders();
            }

            if (_autoChunk)
            {
                _outputFormatter.Append(data.Length, Format.Parsed.HexLowercase);
                _outputFormatter.Write(data);
                _outputFormatter.Write(_endChunkBytes);
            }
            else
            {
                _outputFormatter.Write(data);
            }

            return _outputFormatter.FlushAsync();
        }
Exemplo n.º 3
0
 public Task HandleAsync(Line message)
 {
     // Echo back to the caller
     _formatter.Append(message.Data);
     return(_formatter.FlushAsync());
 }