protected virtual async Task WriteResponseAsync(HttpResponseMessage response, IOutputStream os)
        {
            if (response.Content == null && EnforceHtmlResponseBody)
                response.Content = CreateHtmlResponse(response.StatusCode);

            using (Stream resp = os.AsStreamForWrite()) {

                string header = response.ToHeaderString();
                byte[] headerArray = Encoding.UTF8.GetBytes(header);

                await resp.WriteAsync(headerArray, 0, headerArray.Length);
                if (response.Content != null)
                    await response.Content.CopyToAsync(resp);

                await resp.FlushAsync();
            }
        }