public async Task WriteHeaders() { string header = $"{Version} {(int)StatusCode} {ReasonPhrase}\r\n" + Headers.ToString() + "\r\n"; byte[] headerArray = Encoding.UTF8.GetBytes(header); var socketStream = client.GetOutputStream(); await socketStream.WriteAsync(headerArray, 0, headerArray.Length); await socketStream.FlushAsync(); }
private async Task SendMessage() { var outputStream = OutputStream as MemoryStream; outputStream.Seek(0, SeekOrigin.Begin); var socketStream = _client.GetOutputStream(); string header = $"{Version} {StatusCode} {ReasonPhrase}\r\n" + Headers.ToString() + $"Content-Length: {outputStream.Length}\r\n" + "\r\n"; byte[] headerArray = Encoding.UTF8.GetBytes(header); await socketStream.WriteAsync(headerArray, 0, headerArray.Length); await outputStream.CopyToAsync(socketStream); await socketStream.FlushAsync(); }