Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Also, notice that we are using the robust writen function from Figure 12.15 for all output. The read requesthdrs Function T INY does not use any of the information in the request headers. It simply reads and ignores them by calling the read requesthdrs function in Figure 12.49. Notice that the empty text line that terminates the request headers consists of a carriage return and line feed pair, which we check for in line 6. 658 CHAPTER 12. NETWORK PROGRAMMING code/net/tiny/tiny.c 1 2 3 4 5 6 7 8 9 void read_requesthdrs(int fd) { char buf[MAXLINE]; Readline(fd, buf, MAXLINE); while(strcmp(buf, "\r\n")) Readline(fd, buf, MAXLINE); return; } code/net/tiny/tiny.c Figure 12.49: T INY read requesthdrs: Reads and ignores request headers. The parse uri Function T INY assumes that the home directory for static content is the current Unix directory ’.’, and that the home directory for executables is ./cgi-bin. Any URI that contains the string cgi-bin is assumed to denote a request for dynamic content. The default file name is ./home.html. The parse uri function in Figure 12.50 implements these policies. It parses the URI into a filename and an optional CGI argument string. If the request is for static content (line 5) we clear the CGI argument string (line 6), and then convert the URI into a relative Unix pathname such as ./index.html (lines 7...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online