In this programming assignment we will develop a dummy proxy server. In the end, you will have built a multi-threaded proxy server that is capable of processing multiple simultaneous service requests in parallel. You should be able to demonstrate that your proxy server is capable of retrieving and delivering simple web pages to a Web browser.
We are going to implement part of version 1.1 of HTTP, as defined in RFC 2616 , where separate HTTP requests are sent for each component of the Web page. The server will be able to handle multiple simultaneous service requests in parallel. This means that the Web server is multi-threaded. In the main thread, the server listens to a fixed port. When it receives a TCP connection request, it sets up a TCP connection through another port and services the request in a separate thread.
As you are developing the code, you can test your server from a Web browser. But remember that you need to configure your Web browser to use your proxy server. For example, if you are using netscape7, you need to specify the host name and port number of your proxy server manually by going through the menu [Edit->Preferences->Advanced->Proxies], and type the required information in the HTTP proxy preference box.
In this assignment, you only implement part of the HTTP version 1.1.
Here
are the guidelines you should follow:
Connection
,
Proxy-Connection
, Keep-Alive
,
If-Modified-Since
and If-None-Match
Headers.
If-Modified-Since
conditional
requests.
For the details of the above requirements, you are advised to read RFC 2616 carefully.
The program consists of two classes:
ProxyServer |
HttpRequest |
You need to complete the code in both ProxyServer
class and
HttpRequest
.
The places where you need to complete the code have been marked with the
comments /* Fill in */
. Each of the places requires one or more
lines of code.
The ProxyServer
relays HTTP requests that it receives through a
well-known port number 3128 or 8080. You can choose any port higher than 1024,
but make sure that the same port number is used in the HTTP proxy setting of
your browser. Each time the ProxyServer
receives an HTTP
connection, it calls the multi-threaded class HttpRequest
and
passes the HTTP connection to it for handling the actual request. The
HttpRequest
thread processes the request by connecting to the
destination Web server, retrieving the content corresponding to the request, and
forwarding to the Web browser. After the class HttpRequest
completes the HTTP request, it closes the connections of both the destination
Web server and the Web browser.