Project 1 - Checkpoint 2
For the checkpoint 2, you will be implementing really simple HTTP server, which can only support static contents.
The following list should give you general idea of where you should start.
- Start from the echo server you made for CP1
- Read RFC carefully (annotated version included in resource handout, but encouraged to read the full version on the internet). We know they are sometimes poorly written, but you will encounter so many more of them as you progress. Note that they only specify protocol, not implementation details. You should come up with your own design and architecture for the problem.
- Start from the logging module. It is always great to have some simple facilities to log what kinds of things are happening on your server.
- Handle log file opening/creation/closing
- Make API call (optional: formatted string input would be nice!!) to write to this log file. If you prefer, start off with print out to stdour/stderr instead of testing purposes, and change back to outputing to file once all your work is done.
- Use the API call to log all interesting information (IP address, Browser info. etc.)
- Log all errors and exceptions the server encounters. This simplifies the steps to track down bugs
- Write HTTP/1.1 parser, and subsequent layers supporting http methods (GET/POST/HEAD)
- Parser should work across the boundaries of buffer. Do not assume all request will fit into one buffer
- You must read the file from the disk when requested (out of the specified 'www' directory). No need to implement cache.
- Your server must handle all errors in a sane way. No matter what server gets for its input, it shall NEVER CRASH!!!
- Errors should be reported back to client as HTTP/1.1 error responses. And also they should be logged all onto the log file.
Note that the server from the CP1 can work as to provide blackbox for the underlying select() based server implementation. CP2 concentrates more on the application logic of the server, while CP1 was more about system side setup.
When handing in, please include detailed documentation of your implementation when handing in. This helps us very much to make sense out of your code, and will not deduct unnecessarily. Also, please write clean code. STYLE MATTERS!!
handin procedure for CP2 is same as CP1. But please add some tag on the directory name to indicate it is CP2. (Preferrably, add _cp2 to the directory name)
Last edited at 10:56 PM, Sept. 20. 2012