|   NetProg 2002 HW2 FAQ |
|     Project Description     |    Submission Instructions |
| | |||||||||||||||||||||||||
| | |||||||||||||||||||||||||
| Question: | In lecture on Friday, Dave mentioned providing a string parser for the URL that is passed in a request. Is this code available? |
||||||||||||||||||||||||
| Answer: | The code is available here: parse.c. Please read the comments at the top of the file before considering using this code in your project - there is no guarentee that this code does what you want, works correctly, works at all, etc. Other people have used the code successfully (as far as I know there are no big problems), but there are certain assumptions made about strings... |
||||||||||||||||||||||||
| | |||||||||||||||||||||||||
| Question: | I'm confused as to exactly how our proxy is supposed to know when the server has sent the entire reply. Should we look for EOF or use the "content-length" respone header ? If the server is an HTTP 1.1 server that does support persistence by default then we need to worry about chunking, right? |
||||||||||||||||||||||||
| Answer: | It appears that there are many HTTP 1.1 servers that do support persistent connections by default, this means the server won't close the connection when the entire response has been sent. You can't rely on the reported HTTP version to predict behavior, as the following table shows (compiled from tests I ran using telnet).
The simplest way to resolve this issue is to simply support HTTP 1.0 only, and to tell the server this (regardless of what version of HTTP the client tells you it is using, you use version 1.0 when sending your request to the server). If you want to support 1.1 you also need to worry about chunking (we won't test on servers that do chunking, it appears we won't be able to avoid servers that provide persistent connections by default). To summarize: The simple way to go is to always send requests with the version number set to HTTP/1.0 - then the server won't do chunking or persistence (by default). In your proxy you can read the response from the server until you detect EOF (read returns a 0) - this means the server has closed the connection. | ||||||||||||||||||||||||
| | |||||||||||||||||||||||||
| Question: | How are we supposed to differentiate between ridiculously long requests that are valid web addresses and ones that aren't? Is there a maximum request length that the program is supposed to handle? |
||||||||||||||||||||||||
| Answer: | There is no maximum URI length, but there are practical limits. I would suggest accepting a request line that is up to 1000 characters, this should handle just about anything that is valid. There is some discussion about this in section 3.2.1 of RFC2616, although it does not mention proxy servers (for real http servers the issue is simplified a bit, as they only need to be ready to handle the URI of any resource they serve). We won't test on anything close to 1000 bytes. |
||||||||||||||||||||||||
| | |||||||||||||||||||||||||