November 8th 2010
- by robperson.
- 1 comment
For our Data Communications and Network Programming course we had to develop an HTTP proxy server in C (yes, C. Not C++. Not C#. C). It was a very difficult project and I want to share my code with the world. The funny thing is: after I finished, the code looked SO simple. It turned out I had such a hard time because I tried to read every bit of the Requests and Responses using string libraries. This works fine for plain hypertext but breaks on any binary data that contains a zero byte (which is most pages on the internet). I eventually realized I had to treat the requests/responses as a series of plain old bytes (and not as a long string) and this solved my problem.
Hopefully this information and my source code will be of use to other students.
DON’T STEAL MY CODE. USE IT FOR REFERENCE ONLY!!