Assignment #2 - Conditionals and Persistence

Download Report

Transcript Assignment #2 - Conditionals and Persistence

Web Server Design
Assignment #2: Conditionals & Persistence
Due: 02/24/2010
Old Dominion University
Department of Computer Science
CS 495/595 Spring 2010
Martin Klein <[email protected]>
Grading
• To be done by an automated program that will test
most (all?) combinations
– assignment is listed under the day it is to be demoed in
class
– each group will give a 3-4 minute status report the
week before an assignment is due!
• If you have a question:
– email the class list
– mimic the behavior of a well known Apache server
(e.g., www.cs.odu.edu)
Methods to Support
• Same as assignment #1
• More guidance re: OPTIONS
– mime type response will be “message/http”
– with a content length of 0 (i.e., do not return an entity
body)
– support the “*” URI
– from section 9.2:
If the Request-URI is an asterisk ("*"), the OPTIONS request is
intended to apply to the server in general rather than to a specific
resource. Since a server's communication options typically depend on
the resource, the "*" request is only useful as a "ping" or "no-op"
type of method; it does nothing beyond allowing the client to test
the capabilities of the server.
A 200 response SHOULD include any header fields that indicate
optional features implemented by the server and applicable to that
resource (e.g., Allow), possibly including extensions not defined by
this specification. The response body, if any, SHOULD also include
information about the communication options. The format for such a
body is not defined by this specification, but might be defined by
future extensions to HTTP. Content negotiation MAY be used to select
the appropriate response format. If no response body is included, the
response MUST include a Content-Length field with a field-value of
"0".
Methods to Support
• Any GET method that does not result in a
20X response code MUST have a text/html
entity generated by the server explaining the
response code
HTTP/1.1 301 Moved Permanently
Date: Mon, 16 Feb 2009 03:33:10 GMT
Server: Apache/2.2.0
Location: http://www.cs.odu.edu/~mln/
Content-Length: 305
Content-Type: text/html; charset=iso8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a
href="http://www.cs.odu.edu/~mln/">here</
a>.</p>
<hr>
<address>Apache/2.2.0 Server at
www.cs.odu.edu Port 80</address>
</body></html>
HTTP/1.1 400 Bad Request
Date: Mon, 16 Feb 2009 03:30:12 GMT
Server: Apache/2.2.0
Content-Length: 296
Connection: close
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 501 Method Not Implemented
Date: Mon, 16 Feb 2009 03:34:01 GMT
Server: Apache/2.2.0
Allow: GET,HEAD,POST,OPTIONS,TRACE
Content-Length: 293
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML
<title>400 Bad Request</title>
2.0//EN">
</head><body>
<html><head>
<h1>Bad Request</h1>
<title>501 Method Not Implemented</title>
<p>Your browser sent a request that this server </head><body>
could not understand.<br />
<h1>Method Not Implemented</h1>
</p>
<p>NOTAMETHOD to /index.shtml not supported.<br
<hr>
/>
<address>Apache/2.2.0 Server at www.cs.odu.edu
</p>
Port 80</address>
<hr>
</body></html>
<address>Apache/2.2.0 Server at www.cs.odu.edu
Port 80</address>
</body></html>
Status Codes to Support
• Same as assignment #1, plus:
– 301 Moved Permanently
• if “/foo” is a directory, the server should 301
redirect to “/foo/”
– 302 Found
• takes a configurable list of regular expressions and
provides URIs that the server should 302 redirect to
– 304 Not Modified
– 412 Precondition Failed
302 Redirection
#
# Incoming RE
#
^(.*)/index.html$
^(.*)/1.[234]/(.*)
302 URI
$1/fairlane.html
$1/1.1/$2
Request Headers
• Same as assignment #1, but:
– optional: Connection: close
• implies supporting persistent & long-lived connections
• and add:
–
–
–
–
If-Modified-Since
If-Unmodified-Since
If-Match
If-None-Match
Response Headers
• Same as assignment #1, plus:
– ETag
MIME Types
• Same as assignment #1
Further Guidance
• Only “strong” ETags need to be computed
– see week 3 lecture for a possible implementation
• Use a logical “AND” when combining:
–
–
–
–
–
If-Modified-Since
If-Unmodified-Since
If-Match
If-None-Match
be stingy: all conditions must be satisfied to send data
• if conditionals would yield both 304 & 412, then send only the
304
• Terminate connections after 15 idle seconds
Directory Listings
• Have a configurable file substitute for
directory listing.
– e.g., on requests for “…/foo/”, Apache will
substitute “…/foo/index.html” if it is present.
– our “special file” for A2 will be “fairlane.html”
• Why? Good question! (because we like Fairlanes)
Keep in mind:
Status report next week!
START
NOW!!!