Seems like there’s a huge variety of people stopping by here with all sorts of skillsets and so I’m going to take advantage of that and pick YOUR brain today …
I need to build an application that needs to capture Web requests and Web traffic from a client. If you’ve ever used Microsoft Web Application Stress Tool or ACT in Visual Studio you get the idea. Or heck a better example yet - Fiddler or some similar type of HTTP proxy. Basically I’d like to bring up a browser and capture ALL request traffic the browser is running and capture the HTTP headers to replay them later.
You might think this is pretty easy – after all you can use IE and BeforeNavigate to capture URLs, POST data and headers. Unfortunately BeforeNavigate captures only top level URLS and only those you actually navigated to in some way, not things like images stylesheets etc. There are other events that look like they might work like DownloadFile etc. but none of them seem to capture the supporting files for a page itself. So I don’t think this can be done using the IE COM interfaces.
My next thought was to use some sort of packet filtering and capture the Web traffic that way. There are actually a number of reasonably good free packet capture tools out there for .NET and I played around with that for a while. Problem is most do not work against localhost – they actually need to run a full network connection. Accck... Also, even if I managed to get this to work this seems like a pretty hairy way to go.
The last thing I’ve been thinking of is to build some sort of forwarding proxy. Listen on a proxy port capture the data then forward. But even that looks to be a pretty major undertaking given the way HTTP chunks data – it’s not going to be trivial to put the HTTP responses together properly…
Peter Bromberg suggested taking a look at Fiddler with Reflector – which I did a while back actually, but the proxy stuff in Fiddler is pretty spread out.
I guess I’m wondering what approaches that I missed here or whether somebody knows of some sort of pre-packaged mechanism that can accomplish this task without me having to get my hands into low level network plumbing…
Other Posts you might also like