CSCI561 - Computer Networks
Using the echo server as a starting point, create a minimal Web server.
See Chapter Six of Tanenbaum's Computer Networks, http://www.rfc-editor.org for
RFC 1945 and RFC 2616, and Chapter Three of D. Comer's Computer Networks and Internets.
Each time a hyperlink on a browser web page is clicked, the client
broswer wraps the URL into a "GET" request for the HTTP server. Thus,
your first task is to decide on a mapping scheme from client URL names
to server file names. Each browser GET request will have the following form:
GET*Document_Name *HTTP/1.0 CRLF
Where "*" is zero or more spaces. The "Document_Name" is an HTML file
offered to the Web. "CRLF" is the combination of a carriage return
and the line feed characters. "HTTP/1.0" is the protocol version.
The Apache Web server reads a configuration file, but you can use
program constants for your document root directory, etc.
(Document root simply means the highest level default starting
directory for your HTML documents.)
Modify the echo server to wait for the GET request. Then read and write the
named file into the socket, and close the connection.
Process GET requests for HTML text files and graphic
image files to be sent to the browser (client). In other
words, do not mess with the file contents, just send
the file as a stream of bytes.
Use the last four digits of your Student ID as the port number!
Do not use port 80, since you are not the superuser and you want
exclusive access to your server. And you do not want fight with your
classmates about whose server is whose.
Test your server by invoking a Web browser. Instead of a usual URL,
type in the loop back address and your port number using the
Where "localhost" is the same as 127.0.0.1 and "xxxx" is the last four digits
of your Student ID, the port number, and "document_name" is the file name.
Test your server with another browser from a remote machine.
A browser may request additional information from the server following
the GET request and that additional request is delimited with a blank
line (i.e., CRLF followed by another CRLF). Create a "command decode"
which identify the commands such as GET, but ignores input followed
by a blank line.
Respond to non-existent documents with the following reply:
HTTP/1.0 404 File Not Found CRLF
Server: (Your special message) CRLF
Content-type: (Another message) CRLF
If the document name is a directory:
create an HTML page, in real time, containing the file names
in the directory and send the resulting HTML text page to the client.
Implement the HTTP 302 response that forwards the client GET request
onto another Web server that can process the request.
Do not forget to kill your servers. Please clean up after
yourself and do not leave your servers laying around for
someone else to kill. They will fill the process table and
prevent others from completing the assignment. Thank you.
Once the program is working properly, use the script program
(type "man script" to see how to use it) to show your source changes,
the compiler output, and the execution of the server.
This seems weird, but it works as a server demonstration. Use
telnet to connect to your server. Type "GET ...", you will
see the response and it will be saved in the script file.