AWSSDK_DotNet.IntegrationTests.Tests.Servlet.WriteResponse C# (CSharp) Method

WriteResponse() protected method

protected WriteResponse ( HttpListenerResponse response, string content, int status, string>.IDictionary headers ) : void
response System.Net.HttpListenerResponse
content string
status int
headers string>.IDictionary
return void
        protected void WriteResponse(HttpListenerResponse response, string content, int status, IDictionary<string, string> headers)
        {
            if (headers != null)
            {
                foreach (var kvp in headers)
                {
                    string name = kvp.Key;
                    string value = kvp.Value;
                    if (string.Equals(name, "Content-Length", StringComparison.OrdinalIgnoreCase))
                        response.ContentLength64 = long.Parse(value, CultureInfo.InvariantCulture);
                    else
                        response.Headers[kvp.Key] = kvp.Value;
                }
            }

            response.StatusCode = status;
            byte[] responseBytes = Encoding.UTF8.GetBytes(content);

            using (response.OutputStream)
            using (MemoryStream stream = new MemoryStream(responseBytes))
            {
                response.OutputStream.Write(responseBytes, 0, responseBytes.Length);
            }
        }
        protected virtual void Cleanup()

Same methods

Servlet::WriteResponse ( HttpListenerResponse response, string content ) : void
Servlet::WriteResponse ( HttpListenerResponse response, string content, int status ) : void