
HTTP
1) Firefox has a setting browser. cache. check_doc_frequency entitled "Document is cache is
compared to document on network". The choices are "Every time", "Once per session", and "Never".
For instance, if "every time" is set then the cached document is compared to the servers version every
time the document is displayed to the user. If the documents differ, the new document is loaded. What
would be the most efficient way to implement this feature?
Use a 'Head' command where possible
Use a "Head" command with a 'Send-if-modified' if possible
Use a "Get" command with a "If-Modified-Since" if possible
Use a "Get" command with a "Send-date" or "Send-Etag" modifier if possible
None of these. It's actually ________________________________
2) You want everything to go right. What return code do you hope for from the server?
1. Something in the 100's
2. Something in the 200's
3. Something in the 300's
4. Something in the 400's
5. Something in the 500's
3) Using HTTP/1.1, how can you tell what type the incoming file is?
______________________________________________________________________________
4) Suppose you make an HTTP/1.0 request. You receive data in reply. How can you tell where the
metadata stops and the file contents begin?
Programming
1) As a receiver I execute the code ret = read(sock, buf, 1000); However, the sender
only sends 28 bytes and then closes the socket and then exist. What value will I get for 'ret'?
2) Spock has 3 piles of Mars sand. Kirk has 4 piles of Mars sand. If they put them together, how many
piles do they have? ______________
3) Consider the two programs below. What happens if I launch ONE server and the try and start TWO
clients at nearly the same time?
main() {
struct sockaddr_in sa;
int sa_len;
char hostname[1024];
sa.sin_port = htons(7777);
gethostname(hostname, 1024);
struct hostent *hp =
gethostbyname(localhostname);
bcopy((char *)hp->haddr, (char
*)&sa.sin_addr, hp->h_length);
int sock = socket(hp->h_addrtype,
SOCK_STREAM, 0);
main() {
struct sockaddr_in sa;
int sa_len;
sa.sin_port = htons(7777);
struct hostent *hp =
gethostbyname("euclid.nmu.edu");
bcopy((char *)hp->haddr, (char
*)&sa.sin_addr, hp->h_length);
int sock = socket(hp->h_addrtype,
SOCK_STREAM, 0);