public void WriteFailureHeaders(int errorCode) { string newline = Environment.NewLine; outputStream.Write(Encoding.UTF8.GetBytes("HTTP/1.1 " + errorCode.ToString() + " " + StatusCodes.Lookup(errorCode) + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Content-Type: text/html" + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Server: " + AssemblyTitle.Replace(' ', '-') + '/' + AssemblyVersion + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Date: " + DateTime.UtcNow.ToString(DateTimeFormat) + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Connection: close" + newline)); string data = GetErrorDocument(errorCode); outputStream.Write(Encoding.UTF8.GetBytes("Content-Length: " + data.Length.ToString() + newline)); outputStream.Write(Encoding.UTF8.GetBytes(newline)); outputStream.Write(Encoding.UTF8.GetBytes(data)); }
public void WriteSuccessHeaders(int statusCode, string contentType, byte[] data) { string newline = Environment.NewLine; outputStream.Write(Encoding.UTF8.GetBytes("HTTP/1.1 " + statusCode.ToString() + " " + StatusCodes.Lookup(statusCode) + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Content-Type: " + contentType + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Server: " + AssemblyTitle.Replace(' ', '-') + '/' + AssemblyVersion + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Date: " + DateTime.UtcNow.ToString(DateTimeFormat) + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Connection: close" + newline)); outputStream.Write(Encoding.UTF8.GetBytes("Content-Length: " + data.Length.ToString() + newline)); outputStream.Write(Encoding.UTF8.GetBytes(newline)); outputStream.Write(data); }