SYNAPSE Project

Tom Kelliher, CS 318

Apr. 10, 2000

Administrivia

Announcements

Will return exam Wednesday.

Assignment

SYNAPSE project, due 4/24.

From Last Time

Exam.

Outline

  1. Discussion of project.

Coming Up

Finish socket calls. Start building servers.

SYNAPSE Project

  1. Simple Synchronous Capable Web Server.

  2. Serves: HTML, GIF, JPEG.

  3. Runs: CGI called via GET operation.

  4. Only handles the GET operation.

Design and Grading

  1. Use server.pl as an example of how to initialize the server's socket connection and extract client information (IP, hostname, port).

  2. In your documentation, carefully explain each socket call.

  3. Other items expected in the documentation: program and subroutine descriptions, descriptive variable names and descriptions, separation between subroutines (use of whitespace), commentary within code blocks, where appropriate.

    Subroutine descriptions should describe input parameters and return values, where appropriate.

  4. Design: top-down. Implementation and testing: bottom-up.

    Plan to build two. First, an experimental prototype. Second, the project to turn in.

    Good design important: short subroutines, symbolic constants, don't do more than required (e.g., reading an entire file in at once).

    Vital to think about a build/test sequence:

    1. Get server listening on its port.

    2. Use telnet to send requests, server prints client information and client request.

    3. Still using telnet, server now serves a single HTML file from disk.

    4. Switch over to browser.

    5. Server now serves arbitrary HTML files.

    6. Server additionally server JPEG files. Then, GIF files.

    7. Server executes CGI files.

  5. Testing document. Minimally, exercise all code. 501, 404 status codes.

  6. What to turn in. Late policy, point distribution.

Pseudocode

This is a simplification, a starting point. Do not implement directly from it.

Client Request, Path Interpretation

Example client requests:

GET / HTTP/1.0
POST /handler.cgi?name=kelliher HTTP/1.0
The POST example is contrived. Not shown are the attribute lines, which can be ignored.

Notes:

  1. Each request is terminated with \r\n\r\n.

  2. If the operation is anything other than GET, generate a 501 Not Implemented status page.

  3. All path are relative to document root. If the path is non-existent, generate a 404 Not Found status page.

  4. Association of path extension and content-type attribute.

Server Reply

If client request is GET / HTTP/1.0 server reply is:

HTTP/1.0 200 OK
Connection: close
Content-Type: text/html

<contents of document-root/index.html

Notes:

  1. Empty line separates reply header from reply body.

  2. If running a CGI, CGI generates content-type attribute.

Example of server reply on a 404:

HTTP/1.0 404 Not Found
Connection: close
Content-type: text/html

<HTML><HEAD>
<TITLE>404 File Not Found</TITLE>
</HEAD><BODY>
<H1>File Not Found</H1>
The requested URL <insert path here> was not found on this server.<P>
</BODY></HTML>
501 is similar.

Handlers and Special Cases

  1. Server should work with both Netscape and IE.

  2. IE occasionally sends an empty request.

  3. Netscape occasionally closes a connection early.

    This is handled by the PIPE handler.

  4. TERM handler gracefully shuts down open files and sockets when a Ctrl-c is received.

Sample Web Site

You can use docs.tar as a sample web site. During build/test phase, you may want to add/subtract files.



Thomas P. Kelliher
Mon Apr 10 09:13:56 EDT 2000
Tom Kelliher