- Implementing part of the HTTP protocol.
- Threaded (multiple clients).
- GET / POST / HEAD Methods.
- Error Handling (Page Not found - Bad Request - Redirection - Internal Server Error).
- Accepting multiple clients by starting a thread for each accepted connection.
- Keep on accepting requests from the remote client until the client closes the socket (sends a zero length message).
- For each received request, the server must reply with a response.
- The received request must be a valid HTTP request, else return 400 Bad Request.
- Checking single space separating the request line parameters (Method URI HTTPVersion).
- Checking blank line separating the header lines and the content, even if the content is empty.
- Checking valid URI.
- Checking at least request line and host header and blank lines exist.
- The response should include the following headers:
- Content-Type (We will use only text/html).
- Content-Length (The length of the content).
- Date (Current DateTime of the server).
- Location (Only if there is redirection).
- Using Configuration.RootPath, map the URI to the physical path (See below line for an Example).
configuration.RootPath= “c:\intepub\wwwroot\fcis1” and URI = “/aboutus.html” then physical path= “c:\intepub\wwwroot\fcis1\aboutus.html”
- If the URI exists in the configuration.RedirectionRules, then return 301 Redirection Error and add location header with the new redirected URI.
- The content should be the content of the static page “redirect.html”.
- If the physical file is not found return 404 Not Found error.
- The content should be the content of the static page “Notfound.html”
- If there is any parsing error in the request, return 400 Bad Request Error.
- The content should be loaded with the content of the static page “BadRequest.html”.
- If there is any unknown exception, return 500 Internal Server Error.
- The content should be the content of the static page “InternalError.html”.
- Put inetpub folder in
C Directory
- In Server class line 193 change the
rootfolder
to your downloads folder path. - In server class line 195 change the
xmlDocumentpath
to your xml file path.
To Run and Test the HTTP Servver, here are some links to use:
- http://localhost:1000/aboutus.html (redirection)
- http://localhost:1000/main.html (main)
- http://localhost:1000/blabla.html (404 page)
- http://localhost:1000/formpage.html (post method try to submit the form and see the changes of the xml file)
- Nada Mohamed - Nada Anies
- KAN Org.
- University of Ain Shams, Egypt