This preview shows page 1. Sign up to view the full content.
Unformatted text preview: -8). If the URI ends with a ’/’ character (line 9), then we append the default ﬁle name (lines 9). On the other hand, if the request is for dynamic content (line 13), we extract any CGI arguments (line 14-20) and convert the remaining portion of the URI to a relative Unix ﬁle name (lines 21-22). The serve static Function
T INY serves 4 different types of static content: HTML ﬁles, unformatted text ﬁles, and images encoded in GIF and JPG formats. These ﬁle types account for the majority of static content served over the Web. The serve static function in Figure 12.51 sends an HTTP response whose body contains the contents of a local ﬁle. First, we determine the ﬁle type by inspecting the sufﬁx in the ﬁlename (line 7), and then send the response line and response headers to the client (lines 6-12). Notice that we are using the writen function from Figure 12.15 for all output on the descriptor. Notice also that a blank line terminates the headers (line 12). Next, we send the response body by c...
View Full Document
- Spring '10
- The American