views:

134

answers:

4

My application is performing numerous HttpWebRequests, and some of them fail occasionally. I would like to dump the bytes leaving my PC whenever I perform a request as well as the bytes arriving as a response.

Is it possible to do this from within my code easily?

I'd only like to use something like Wireshark as a last resort if no other method is available, as I'd like such dumping to be available on the clients' machines without having to install WinPcap and stuff.

+1  A: 

Check out Fidller2 -- yeah it is installing something, but it's not anywhere near as involved as wireshark and it will give you much more useful information. Including being able to dump the streams into re-playable series.

Wyatt Barnett
This doesn't really answer the question but was very helpful nevertheless. For the record, I found no way of doing exactly what the question asks.
romkyns
A: 

There is Microsoft's NetMon or as you said a WinPCap based product like Wireshark. Just like Wireshark, it can be overkill for just HTTP.

As the other post said, there is Fiddler2 is a lot easy to use for debugging HTTP. Also it is useful in debugging HTTPS where NetMon/Wireshark is of no use...

Shane Powell
A: 

What I'm doing now is wrapping HttpWebRequest into a class which just dumps all the response headers and body into a specified file. Same for the request, though it's a bit clumsy with POST requests.

The worst thing about this is that I have to change all code that uses HttpWebRequest to use this new wrapper class, but it's not too bad.

romkyns
Now that it's been a couple of months, the wrapping solution made a bunch of other things easier too, so overall I think this was the right decision for my particular use case.
romkyns
A: 

You have a couple of options:

  • HttpFox - This is my favourite tool. It's a firefox plugin, has filtering capabilities and neatly shows all the data for request, response, headers and formats the output for easy legibility.
  • Fiddler - This is my second choice. It works across all browsers and provides all the HTTP traffic details
  • WFetch - This is slightly different in that you have to create your on HTTP request for which it shows the server's HTTP response. This is great for debugging web services and sending out hand crafted JSON etc. I usually grab the data from HTTPFox and then paste it into WFetch, modify it in certain ways and then debug my service.
  • Firebug - Also shows HTTP traffic for the domain. I use Firebug for everything but HTTP traffic debugging but it's still pretty good if you don't want to install HTTPFox.
aleemb