/// <summary>Processes the provided request and generates a server response</summary> /// <param name="request">Request to be processed by the server</param> /// <returns>The response to the server request</returns> protected virtual Response ProcessRequest(Request request) { #if true // GENERATE_DUMMY_RESPONSE Console.WriteLine( DateTime.Now.ToString() + " Processed request for " + request.Uri ); // Here's the HTML document we want to send to the client MemoryStream messageMemory = new MemoryStream(); StreamWriter writer = new StreamWriter(messageMemory, Encoding.UTF8); writer.WriteLine("<html>"); writer.WriteLine("<head><title>Hello World</title></head>"); writer.WriteLine("<body><small>Hello World from the Nuclex Web Server</small></body>"); writer.WriteLine("</html>"); writer.Flush(); // Prepare the response message Response theResponse = new Response(StatusCode.S200_OK); // Add some random headers web server's like to provider theResponse.Headers.Add("Cache-Control", "private"); theResponse.Headers.Add("Content-Type", "text/html; charset=UTF-8"); theResponse.Headers.Add("Date", "Wed, 30 Jul 2008 14:01:06 GMT"); theResponse.Headers.Add("Server", "Nuclex"); // Attach the HTML document to our response theResponse.AttachStream(messageMemory); // Now comes the important part, specify how many bytes we're going to // transmit. // TODO: This should be done by parseRequest() // Whether it's needed or not depends on the transport protocol used messageMemory.Position = 0; theResponse.Headers.Add("Content-Length", messageMemory.Length.ToString()); #endif return theResponse; }