Your assignment is to write a simple Web server using Java or your preferred programming language. Use HTTP v. 1.1. Implement only the features indicated below. Full details on HTTP/1.1 can be found at www.w3.org/Protocols/rfc2616/rfc2616.html.

Methods

GET — Request from client (browser) for file. Syntax: GET path version The request is normally followed by several headers. Sample GET request: See image.

Note: your server usually can ignore headers that it doesn't understand. It cannot ignore the connection header.

Server Response: See image.

HEAD — Request from client for header data A HEAD request and reply are the same as a GET request and reply, except that in the HEAD reply nothing follows the headers (even though the header will say it does).

POST— client sends data to server. You are not expected to implement POST.

Server Status Codes: You are expected to implement these. You must have prepared-in-advance 400, 404, and 500 pages. Implement 500 with exception handling.

  • 200 OK Successful request; response contains the requested data.
  • 400 Bad Request Syntax error in client's request.
  • 404 Not Found Document specified in the URI does not exist.
  • 500 Internal Server Error Any error (e.g., runtime error) within the server.

Headers — General

  • Connection: Keep-alive Don't close the connection: more transactions to come.
  • Connection: close This is the last transaction: close the connection.

Headers — Client Request

Host: hostname[:port] Hostname and port with which the client is addressing the server. Remember, one server may have multiple domain names, so this way it can find out which domain name the client is addressing.

Headers — Entity

  • Content-Type: type/subtype Type of data served. Typically text/html or image/png.
  • Content-Length: n Data is n octets long.

File Paths: Your server could assume that Web pages are stored in the same directory as the web server program. You choose port number 8000 for your Web service.

TCP/IP Details

Your server should use TCP, not UDP, for transport, because reliability is important to the application. This server must be a concurrent server to handle multiple requests efficiently. Use the multithreaded TCP server example as the starting point.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.