Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture HTTP Traffic

Tags:

c#

http

Short version:
I am looking to make sure that a URL (partial match) is requested (client-side).

Long Version:
I am looking to automate part of my testing. Currently I use Fiddler2 to manually verify.

Here's the scenario:

  1. User navigates to Site A
  2. My app redirects using a tracking URL (seen in Fiddler's HTTP traffic)
  3. User ends up on Site A, parameters now applied.

I would like to verify, in C#, that step 2 happened by doing a partial match (contains {string} for example).

Question:
How should I go about this? I have started looking into HttpWebRequest class and FiddlerCore, but my love using the simplest code possible (so other team members to update if needed) lead me to ask what the users of StackOverflow would recommend.

like image 881
kirbycope Avatar asked Sep 05 '12 22:09

kirbycope


1 Answers

Take a look at SharpPcap. It's based on pcap (WinPcap on Windows), which is the packet capture library that is used by the popular Wireshark.

There is a really great tutorial on CodeProject with lots of example code to get you started: http://www.codeproject.com/Articles/12458/SharpPcap-A-Packet-Capture-Framework-for-NET

Once you have a hold of the packets (SharpPcap does capture, not parsing), you can use Packet.Net to parse the packets into something usable (HTTP communications, in your case).

like image 113
Chris Laplante Avatar answered Sep 24 '22 17:09

Chris Laplante