Without looking into the code:

http://www.fiddlertool.com/fiddler/

Is a great tool for debugging the http traffic of your applications.