Apps

Using Fiddler to debug HTTP

Justin James offers tips and strategies on how to use Fiddler for debugging HTTP sessions. He says this should cover your needs for most scenarios.

I use Fiddler on a regular basis for debugging HTTP sessions, and in this post, I will give a brief walk-through of how you can use Fiddler as well.

First, you will need to download Fiddler (you may want to check out some of the various Fiddler add-ons). Once you go through the easy installation, you will be able to start Fiddler (Figure A). Figure A

Fiddler after starting up (Click the image to enlarge.)

In the lower left corner of Figure A, you will see "Capturing," which means that it is recording HTTP traffic. To toggle recording on and off, you can click the Capturing label, press [F12], or use the option on the File menu. If the screen ever gets too cluttered to work with, you can go to the Edit menu and choose Remove and select what data you wish to delete from the display.

Each line on the left represents an HTTP connection that was made. By selecting a line, you can inspect its contents. Make sure that AutoDecode at the top of the screen is selected so that any compressed HTTP traffic is showed decompressed. Look to the right half of the screen for the details. You will see on the top a variety of tabs. The most-used section is Inspectors, which allows you to see what the details of the HTTP request and response were. When in the Inspectors tab, there are additional tabs for the bottom half that allow you to look at different aspects of the request and response. TextView, Raw, and XML are the three tabs that I find most helpful. TextView shows the body of the response as plain text, Raw shows the entire response, and XML displays XML in a collapsible XML browser view.

Something that you will want to take care of pretty quickly is to set Fiddler up to work with HTTPS traffic; after all, a lot of the services and applications that you will want to debug use encryption. Another nice feature is the ability to allow remote connections (this is found under Fiddler's options). With this option set, you can have other computers route their HTTP traffic through your running copy of Fiddler by setting the proxy settings in the network or browser, and then you can debug their traffic as well. On the topic of debugging, you will want to check out the Request Builder tab at the top right; it allows you to custom create an HTTP request, and it is a perfect way to test Web services (especially REST-ful ones). You can go to the Filters tab in order to do things like establish conditional breakpoints and not display traffic that meets certain requirements, which is great when working on a system with a ton of traffic.

Fiddler has a number of additional pieces of functionality, but this should cover your needs for about 90% of scenarios. Please share any additional tips or Fiddler strategies in the discussion. I'd love to hear them!

J.Ja

About

Justin James is the Lead Architect for Conigent.

13 comments
mattohare
mattohare

I had a hell of a time with connecting to paypal. This cut out a lot of the mystery.

Dampflok
Dampflok

1. Installed it. 2. Ran it. 3. It went berserk downloading several hundrod files. 4. Couldn't close it. 5. Shut off laptop. 6. Now I cannot access network, not get any restore points to work.

Dethpod
Dethpod

I mean besides working with IE? I have used Fiddler a while back but went back to using Firebug. Firebug shows all the traffic back and forth as well as json record sets (and raw json) plus a host of other indispensable tools like JS debugging.

codepoke
codepoke

The ability to export sessions is pretty cool, but it's extra snazzy to export session to a WCAT script and have several hundred virtual surfers replay them against your server. I've not had much luck with state-heavy sites, but it's served me well on a couple simple ones. One solid revelation Fiddler's given me a couple times is whether I'm using NTLM or Kerberos (Negotiate) to authenticate against a site. IIS defaults to Negotiate,NTLM, but MS recommends NTLM for most applications. We'll occassionally have a site just randomly begin 401-ing all visitors. Once Fiddler reveals the site's using Negotiate we just switch it over to NTLM and everything gets happy again.

Andylb
Andylb

It is a nice tool, though I prefer Firebug + Codeburner and sometimes Tamper Data.

e_lawrence
e_lawrence

1> Fiddler doesn't "download" anything. There was some other process doing downloads. If you wanted it to stop collecting them, you can press F12 as was directed. 2> Even if the UI was overloaded and your laptop was so slow that it was temporarily hung, when the traffic flow stopped, it would unhang and you could close it or use it normally. 3> When you killed Fiddler without shutting it down properly, your proxy settings were left pointed at the (not-running) Fiddler instance. If you restarted Fiddler, they'd be fixed for you automatically. Since you didn't, they're not. You can fix them yourself if you like. In IE, click Tools, Internet Options, Connections, Lan Settings, and unset the proxy. Incidentally, that's exactly what would have happened if you pushed the big "Diagnose Connection Problems" button on the error page you're seeing when you say you "cannot access the network." Just so you understand that you're not dealing with some random application, Fiddler has millions of users, and has been publicly available for 8 years.

Justin James
Justin James

That is *really* strange, seeing as it doesn't do any downloads of its own, other than checking for updates (when an update is found, it merely lets you know that the update is available), which involves one HTTP download. I've never heard of anyone having an issue with it either. I'd try uninstalling it. Do you have any unusual items installed like a third party VPN client or something else that might be sitting on top of the TCP/IP stack? J.Ja

Justin James
Justin James

I haven't used Firebug's HTTP debugging tools (I have used its HTML, JS, and CSS stuff a lot though), but it stands to reason that if you need to debug something other that Firefox, Firebug won't help you at at.. J.Ja

KDee
KDee

You can set fiddler up to pause when it sees a particular request going past, letting you get in there to modify the request or the response. You can make modifications by typing in some change to what the client or server sent, or get it to return the content of a file, or return an HTTP error response. And you can also export one or more request/response pairs in an archive format, which can then be imported to fiddler for examination, so you can let other developers see snippets of the traffic to diagnose problems.

SoftwareArchitect
SoftwareArchitect

I haven't used Fiddler myself, but I know the closest option on OS/X is a program called Charles Web debug Proxy (http://www.charlesproxy.com/). Like Fiddler, it's invaluable when you need to look behind the curtain.

Justin James
Justin James

It is a *very* nice tool... for working with HTTP, it's much better than any general purpose packet capture tool I've used, simply because it's so specialized. It will even debug HTTP sessions from WP7 apps running in the emulator (and I'd assumed Android apps as well in its own emulator), allowing you to see why they are having issues. Sure beats the alternative (sending the I/O to a watchpoint or a text file for inspection)! J.Ja

Dampflok
Dampflok

The interesting thing was that my pc was reporting that it was connected to the network but attempts to access it (using Firefox) failed. I went through the network settings and found nothing wrong. Finally found that the proxy settings in Firefox had been changed from auto-detect to manual. It was a case of chasing the wrong problem. As for the rapid series of downloads, as far as I could see these were all of pages currently open in the Firefox tabs. The vast majority were of a financial site that auto-updates its pages, though whether that was anything to do with it. I will never know as I have uninstalled Fiddler2 and won't try again. Sorry not to be able to help further. What puzzles me is why none of the restore points worked. I see no reason why they shouldn't, even if they needed network access to work.

Editor's Picks