|
Please note: The FiddlerAPI is still under construction,
and future releases may require changes to your Inspector plugins. Thanks for your
patience.
Building Fiddler Inspectors
Building custom Inspector objects for Fiddler is easy!
You can use any .NET language, although I'll present my examples in C#.
Note: Fiddler v2.x loads
only .NET CLR v2.0 assemblies; use Visual Studio 2005+
to compile your extension. You should also ensure your project targets
AnyCPU to ensure that it works
properly with 64bit Fiddler.
Working with the new Inspector2 interfaces
If you have inspectors written for older versions of Fiddler, please see
Porting Extensions to Fiddler v2.1
Step-by-Step
-
File | New Project
-
Pick VC# Projects | Class Library
-
Type a name, e.g. WebBrowser
-
Hit OK.
-
In Solution Explorer, right-click References and choose
Add Reference
-
Hit Browse and find Fiddler.exe
-
On the .NET tab, you probably want to add a reference to
System.Windows.Winforms as well.
-
Ensure both libraries are in the Selected Components List and hit
OK.
In Solution Explorer, rename Class1.cs to whatever, e.g.
WebViewer.cs
Change the code to derive from the Inspector2 class. Also, implement
either IResponseInspector2 or IRequestInspector2.
using Fiddler;
[assembly: Fiddler.RequiredVersion("2.1.1.0")]
public class WebViewer: Inspector2, IResponseInspector2 { public Viewers() { // // TODO: Add constructor logic here // } }
Inside the class, create a new method. By typing public
override, you'll get an autocomplete list of the methods you need to
write.
In Solution Explorer, right-click on the project and choose Add | User
Control
Use the Toolbox to add controls to your user control-- these
will show the data about the HTTP message under Inspection.
In the body{ set } and headers{ set }
properties,
you should update your control's visual representation of the request or
response.
Almost done...
If you need help or have questions, please email me using the
Contact link above.
TextViewer.cs using System;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using Fiddler;
[assembly: Fiddler.RequiredVersion("2.2.7.0")]
namespace Standard
{
public class RequestTextViewer: Inspector2, IRequestInspector2
{
TextView myControl;
private byte[] m_entityBody;
private bool m_bDirty;
private bool m_bReadOnly;
public bool bReadOnly{
get {
return m_bReadOnly;
}
set{
m_bReadOnly = value; // TODO: You probably also want
to turn your visible control CONFIG.colorDisabledEdit (false) or WHITE (true) here depending on the
value
being passed in.
}
}
public void Clear(){
m_entityBody = null; m_bDirty = false;
myControl.txtBody.Clear();
}
public RequestTextViewer()
{
// TODO: Add constructor logic here
}
public HTTPRequestHeaders headers{
get {
return null; // Return null if your control doesn't
allow header editing.
}
set{
}
}
public byte[] body
{
get
{
return m_entityBody;
}
set
{ // Here's where the action is. It's time to
update the visible display of the text
m_entityBody = value;
if (null!=m_entityBody){
myControl.txtBody.Text =
System.Text.Encoding.UTF8.GetString(m_entityBody); // TODO: Use correct encoding
based on content header.
}
else {
myControl.txtBody.Text = "";
}
m_bDirty = false; // Note: Be sure to
have an OnTextChanged handler for the textbox which sets m_bDirty to true!
}
public bool bDirty
{
get
{
return m_bDirty;
}
}
public override int GetOrder()
{
return 0;
}
public override void AddToTab(System.Windows.Forms.TabPage o)
{
myControl = new TextView(this); // Essentially the TextView
class is simply a usercontrol containing a textbox.
o.Text = "TextView";
o.Controls.Add(myControl);
o.Controls[0].Dock= DockStyle.Fill;
}
}
}
Debugging your Inspector
Developers should set
the
fiddler.debug.extensions.showerrors preference to ensure that
exceptions and other extension-related errors are not silently caught.
©2010 Microsoft Corporation
|