Redirect traffic to localhost, including HTTPS tunnels

3 posts, 1 answers
  1. coolBlue
    coolBlue avatar
    9 posts
    Member since:
    Aug 2015

    Posted 20 Aug 2015 Link to this post

    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. Answer
    Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 20 Aug 2015 Link to this post

    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}

  3. coolBlue
    coolBlue avatar
    9 posts
    Member since:
    Aug 2015

    Posted 20 Aug 2015 Link to this post

    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. 

Back to Top