Adding rules on .NET application?

143 vistas
Ir al primer mensaje no leído

Nicola Verdoni

no leída,
23 abr 2014, 8:23:33 a.m.23/4/14
para httpf...@googlegroups.com
Hi all guys, i'm new on FiddlerCore.. And i get stucked with lots of questions.

First of all: i'm trying to create a .NET application that has FiddlerCore inside, because i don't want clients to download Fiddler2.exe on theyr own machines.

I was using Fiddler2.exe to testing my app, and it works: with external exe, it works fine.

Let me explain better: i just need a function of Fiddler, maybe twice: AutoResponder, using RuleEditor and "Regex:()" autorespond.

When I set rule on Fiddler.exe, i write:
regex:(?ix)http://(?>(?:\w+\-*\w+\.)?TESTSITE\.(?>\b\w{2,}\.\b)*(?:[\da-z]){2,3}|TESTSITE-[\d]+\.(?:ah|MYVAR)\.bpcdn\.net)/(?=(?:\w+/)?(?<o1>client/))(?=(?:\k<o1>)?(?<o2>(?:res/)?(?:(?<tree>apples|fx|pet|monster|items|mapfield|effects|uiElements|gui|uiConfig|minimaps|api|daynamo)/)))(?:\k<o1>|\k<o2>){2}(?<res>[\w_\-]*(?:\.cfg)?(?!\.php)|dlc(?=\.php)|getDailyTip(?=\.php))\.(?<type>swf|png|xml|php|css)(?:\?.*)?$

and then, in "what to respond", i set


or, instead of URL of folder, i set manually my local folder 
C://Data/$1/mods/$1.$0


that's fine, on Fiddler2.exe.. But how can i set that using FiddlerCore.dll into my .NET application? I'm using C#, and i'm gonna get crazy cause i tryied everything.. But i can't find no solutions in blogs, or even trying.

PLEASE! Help me!

EricLaw

no leída,
23 abr 2014, 4:19:43 p.m.23/4/14
para httpf...@googlegroups.com
Your question could be restated as: How do I implement an AutoResponder using FiddlerCore?

Fully implementing the AutoResponder would be non-trivial, requiring hundreds of lines of code. But if your goal is to simply match HTTP URLs to load files from disk, it's not that hard.

Inside the OnBeforeRequest function, match your regular expression against the Request URL and set the X-ReplyWithFile flag on the session.

So, you'd do something like

  Regex r = new Regex(sRegEx);
  oSession["X-ReplyWithFile"] = r.Replace(oSession.fullUrl, "C:\\Data\\$1\\mods\\$1.$0").Replace('/''\\');

You'll want to make sure your RegEx starts with a ^ character marking the front of the string.

If you wanted to simply change from one HTTP URL to another, you'd just update the fullUrl property directly, and drop the .Replace call at the end of the code snippet.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos