Project 2: Multithreaded Web Server
You say that the server should be a functional HTTP/1.0 server. Is
there a specific specification we should be following? I found this
website http://www.jmarshall.com/easy/http/.
It had some information about GET/HEAD/POST. Should we be implementing
these?
The web page that you point out is a good intro to HTTP.
Specifications for HTTP/1.0 should all be the same. I hope you're not
finding differences in the specs--maybe just in their wording.
You should implement all three, GET/HEAD/POST. For the POST
requests, you're not redirecting requests to a script or an
application to handle the requests, so you can basically treat them
like GET requests. You'll just ignore the irrelevant data that a
client sends. HEAD is a little less work than the other two, so you
may want to start with HEAD.
How should I get started?
You should be able to easily get the basic server started, accepting
connections from clients. (Refer to the examples from class on July
27.)
Try using a browser to connect to your server (on the appropriate
port) and see what the client sends you. This should help you get an
idea of what the HTTP protocol is, if the link above doesn't help.
Another independent starting point is to parse the XML
configuration file and get the configuration data out of it. You can
use the example code from class (080106) to get you started.
What file types do we need to support? Or, am I thinking the wrong
way, and file types are handled on the client end and not on the
server?
Your web server does need to know the type of the file so that it can
send the correct type back to the browser. (We saw something similar
in our servlets, which had to say that the content type was
"text/html".)
Your server should handle the following types of files:
- HTML files: the content-type is "text/" followed by the file extension
- Text files: the content-type is "text/plain"
- Images: the content-type is "image/" and the type of the file, e.g.,
"image/jpeg"
For other files, you can find out the content types from your
browser by viewing the file's information. You can support other file
types for extra credit (up to 5 points).
Do we need to handle directories?
Yes, you do. You should first check if the welcome files are in the
directory. Otherwise, what does a web server give you if none of the
welcome files is there?
Do we need other test cases besides the CIS home page?
Yes, you do. You should be able to demonstrate the full functionality
of your web server.