Second assignment is about coding a simple web proxy. No local storage (no cache handling). Just a simple iterative server but with a twist: As you need to read from two streams (request and response) you have to figure out the best way of doing it.
Only GET method is permitted, so you can safely reject any other method coming from the browser (to keep things as simple as possible).
You can click on this entry title to get the assignment text. Second assignment due date is December 23rd, 2009.
Subscribe to:
Post Comments (Atom)
1 comment:
The idea of using threads is to make your life easier not more difficult. I've made my implementation (binary on file repository) using a single thread.
The problem when reading from two sockets is the possible deadlock. That is why I suggested two threads. However there is no real need for them. The good thing about threads is they can be waiting forever happily without your server getting stuck.
That said, the truth is that if you have paid attention in class, HTTP is a client/server protocol, so a request is sent at the beginning and then you get the response from the server. So you could have your code to:
1) read request from web browser
2) forward a somehow modified request to the server
3) read the response from the server
4) forward (maybe while reading in 3) the response to the web browser
Anyway you can create a class that takes two socket parameters and just copies data from input to output till there is no more data.
Post a Comment