Hints for Completing Lab 7 The due date for the lab is Friday, May 2, at 11:59pm. The last possible hand in time for Lab 7 is Sunday, May 4, at 11:59pm. In order to hand in your lab on Sunday, BOTH partners must have two late days remaining.
Copy the latest versions of csapp.c and driver.pl from /afs/cs/academic/class/15213-s03/labs/L7.
You'll get the "Can't get peer name" error if call format_log_entry with a closed socket.
Use the RIO library, but for supporting https connections, you should NOT use the buffered read functions Rio_readn, Rio_readnb, and Rio_readlineb. Use Rio_readp instead.
Ignore SIGPIPE signals by installing the "ignore" handler using signal(SIGPIPE,SIG_IGN);
When EOF is detected while reading from the server socket, send EOF to the client socket by calling shutdown(clientfd,1); (and vice versa)
The proxy should pass all request headers from the client on to the server, with the following possible exception: You may want to strip off any request header of the form: "Proxy-Connection: Keep-Alive". Otherwise the server may expect the proxy to maintain a persistent connection, which your proxy is not required to do. Passing this header on without actually supporting persistent connections may cause sites like www.google.com and www.cnn.com to "hang" when viewed through a browser.
After passing the request headers on to the server, the proxy also MUST pass a line consisting only of "\r\n" (to tell the server that there will be no more request headers).
To support https connections, your proxy must read from the client and server sockets simultaneously.
As explained in the lecture notes, after opening the socket that listens for new connections, you should set the socket options so that when your proxy exists, the port can be immediately reused the next time you start the proxy. This is required by the driver.pl program, which will stop and restart your proxy. The function call that you will use looks something like
optval = 1; setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (const void*)&optval, sizeof(int));