Program 3: HTTP/1.0 Proxy Server

CS 455/555, Fall 2007, Weigle

Assigned: Tuesday, October 23, 2007
Due: Tuesday, November 13, 2007 before class


Description

For this assignment, we will be combining the HTTP client and HTTP server written for Program 2 into an HTTP/1.0 proxy server. Remember that a proxy server typically receives a request from a web client, checks its cache, and if the information is not in the cache, passes the request to the web server. The response is returned to the proxy server and is stored in the cache. Finally, the the proxy server returns the response to the client.

Your assignment is to write a simple HTTP/1.0 proxy server that logs the URLs requested, forwards the requests to the server, and forwards the responses to the client. You are not required to actually implement a cache. Remember that non-persistent connections are the default in HTTP/1.0.

Important points from RFC 1945 (HTTP/1.0):

"A proxy is a forwarding agent, receiving requests for a URI (MCW: URI is essentially the same thing as URL) in its absolute form, rewriting all or parts of the message, and forwarding the reformatted request toward the server identified by the URI." (Section 1.3)

"Proxy and gateway applications must be careful in forwarding requests that are received in a format different than that of the application's native HTTP version. Since the protocol version indicates the protocol capability of the sender, a proxy/gateway must never send a message with a version indicator which is greater than its native version; if a higher version request is received, the proxy/gateway must either downgrade the request version or respond with an error." (Section 3.1) (MCW: Your proxy must downgrade the request version.)

"The two options for Request-URI are dependent on the nature of the request. The absoluteURI form is only allowed when the request is being made to a proxy. The proxy is requested to forward the request and return the response." (Section 5.1)

Requirements


Rules and Notes


Testing

  • Your program will be graded on how well it satisfies the requirements in handling a set of test URLs. You should test your program rigorously with various URLs before submitting.
  • Any web browser should be able to talk to your proxy server once you change the proxy settings. (Do not change proxy settings on lab machines!) If you do not have access to something other than a lab machine, modify your HTTPClient from Program 2 to use your proxy server (send the request with the full URL in the GET line and connect to the proxy server instead of the web server).
  • Your proxy server should be able to talk to your HTTPServer from Program 2.

  • Helpful Hints

  • Make sure that your URL parser can handle URLs that contain special characters (including ':') in the path.
    For example: http://sb.google.com/safebrowsing/update?client=navclient-auto-ffox&appver=2.0.0.7&version=goog-white-domain:1:23
  • Flush the output file after each write. You can also setup PrintWriter to automatically flush the file.
  • readLineBytes is a helper method that you may use in your program. It takes a DataInputStream object as a parameter and returns a String. This will allow you to read from the socket one line at a time just like readLine(), but it will not corrupt binary data. Note that just like readLine(), it will strip off the "\r\n" from text lines.

  • Submission

    You must name your HTTP proxy server source file HTTPProxyServer.java. Make sure that you submit all files necessary to compile your program, but do not submit the .class files.

    555-only: Also submit your modified HTTPClient.java.

    Directions for submitting your assignment through Blackboard