Example #1
0
 internal static void doGetFavicon(Request request, Response response)
 {
     printResource(Assembly.GetExecutingAssembly(), "Topeka.img.favicon.ico", "ico", request, response);
 }
Example #2
0
 internal static void doGetIndex(Request request, Response response)
 {
     response.println("<img src=\"Topeka.png\" border=0 /><br>");
     response.println("<font size=1 face=verdana>");
     response.println("A lightweight multi-threaded free and easy to use Web Server<br>");
     response.println("Programmed by <b>Juanchi</b> @ 2010<br>");
     response.println("Server Started: <b>" + request.server.startTime + "</b></br>");
     response.println("Server Version: <b>"+Assembly.GetExecutingAssembly().GetName().Version.ToString()+"</b><br>");
     response.println("</font>");
 }
Example #3
0
 /// <summary>
 /// The virtual method that needs to be overriden to handle POST requests
 /// </summary>
 /// <param name="request">The Request object containing information about the request received from the client</param>
 /// <param name="response">The Response object that will be used to send data to the client</param>
 public virtual void doPost(Request request, Response response)
 {
     doGet(request, response);
 }
Example #4
0
 /// <summary>
 /// The abstract method that needs to be overriden to handle GET requests
 /// </summary>
 /// <param name="request">The Request object containing information about the request received from the client</param>
 /// <param name="response">The Response object that will be used to send data to the client</param>
 public abstract void doGet(Request request, Response response);
Example #5
0
 /// <summary>
 /// This method is called when the server detects a parameter "method" in the list of parameters
 /// Example: Users?method=AddUser will try to invoke the method AddUser from the class Users 
 /// </summary>
 /// <param name="type">The type of the Servlet subclass</param>
 /// <param name="method">The method name, in string format</param>
 /// <param name="request">The Request object used to handle this request</param>
 /// <param name="response">The Response object used to handle this request</param>
 internal void invokeMethod(Type type, string method, Request request, Response response)
 {
     object ibaseObject = Activator.CreateInstance(type);
     // Create the parameter list
     object[] arguments = new object[] { request, response };
     object result;
     // Dynamically Invoke the Object
     result = type.InvokeMember(method,
                              BindingFlags.Default | BindingFlags.InvokeMethod,
                              null,
                              ibaseObject,
                              arguments);
 }
Example #6
0
 internal static void printResource(Assembly assembly, string resource, string extension, Request request, Response response)
 {
     Stream stream = assembly.GetManifestResourceStream(resource);
     response.setContentType(Response.getMimeType(extension));
     BinaryReader reader = new BinaryReader(stream);
     byte[] bytes = new byte[stream.Length];
         int read;
         while ((read = reader.Read(bytes, 0, bytes.Length)) != 0)
         {
             response.print(bytes);
         }
         reader.Close();
 }
Example #7
0
 internal static void doGetTopekaLogo(Request request, Response response)
 {
     printResource(Assembly.GetExecutingAssembly(), "Topeka.img.Topeka.png", "png", request, response);
 }