This is a migrated thread and some comments may be shown as answers.

Redirect traffic to localhost, including HTTPS tunnels

2 Answers 2121 Views
Windows
This is a migrated thread and some comments may be shown as answers.
coolBlue
Top achievements
Rank 1
coolBlue asked on 20 Aug 2015, 09:44 AM

I would like to use FiddlerScript redirect to my local files while testing, without having to change the script tags in my HTML.

I'm fine with redirecting specific files using the AutoResponder, but how can I redirect any resource in a particular folder, including for HTTPS tunnel request?

I tried this and other permutations but I don't really understand what I'm doing...

        if (oSession.HTTPMethodIs("CONNECT") && (oSession.PathAndQuery == "rawgit.com:443")) { 
            oSession.PathAndQuery = "localhost:63342";
            oSession.url = oSession.url.Replace("repo/cool-Blue/d3-lib/master/inputs", "inputs");
            oSession["ui-color"] = "red";
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Eric Lawrence
Telerik team
answered on 20 Aug 2015, 03:05 PM
Hi, cool--

Typically, the way that you would redirect an entire folder of resources is to create a RegEx rule. For instance, here's an example from the Fiddler book:

The replacement functionality is smart enough to swap forward-slashes for backslashes when mapping URLs to files, so the rule:

Match Text

Action Text

REGEX:(?insx).+/assets/(?'fname'[^?]*).*

C:\src\${fname}

 …will map a request for http://example.com/‌assets/img/1.png?bunnies to C:\src\‌img\‌1.png.


Now, if you need to handle a CONNECT Tunnel in the AutoResponder, you should do something like:


Match Text

Action Text

METHOD:CONNECT rawgit.com

*ReplyWithTunnel

This will cause Fiddler to respond to any request to CONNECT for rawgit.com with a decrypting HTTPS Tunnel.

Regards,
Eric Lawrence
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items


Match Text

Action Text

REGEX:(?insx).+/assets/(?'fname'[^?]*).*

C:\src\${fname}

0
coolBlue
Top achievements
Rank 1
answered on 21 Aug 2015, 01:59 AM

Capture groups!!!

Works like a charm.

Cheers Eric, that's what I instinctively wanted to do, but I failed to read the fine print in the docs. 

Tags
Windows
Asked by
coolBlue
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
coolBlue
Top achievements
Rank 1
Share this question
or