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

Autorespond with script

5 Answers 1101 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 07 Sep 2015, 01:21 PM

Hi there,

can you help me? I want to search and replace ainside a html-file.

It means there is a request like "index.html" and than I want to replace a part of this with a local snippet and at the end it should be delivered to the brower as "the respond"

 

At the Moment I write a Funktion and call it

*script:TestFunc

It is called because I see a log, but I do'n't know what's next :-/

Thanks!

 

Cya

Dominic

5 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 08 Sep 2015, 09:22 PM
The AutoResponder's *script rules are run on requests, not responses. The AutoResponder is used to respond to requests itself, not to manipulate responses from the network. If you had an already complete response (or could create one entirely from script without hitting the network) you'd use a *script rule.

From the sound of it though, you want your request to be sent to the network and you just want to modify the response that comes back. If so, what you need to use is script inside your OnBeforeResponse ​method. See e.g. http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse 

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
0
Dominic
Top achievements
Rank 1
answered on 09 Sep 2015, 09:27 AM

Thanks for your answer.

To use the OnBeforeResponse ​method it's not a good way for me, I know this method. I had to switch this rules on/off in a simple way.

What to you think about this:
1. the requests...
2. I load the original site with js
3. I modify the original site
4. I return the motified site as the response

 

 Do you have a small example how I can give a response with a script?

Thanks!

 

Cya
Dominic

0
Dominic
Top achievements
Rank 1
answered on 09 Sep 2015, 09:32 AM
I mean an example ​with a static response at a script :-)
0
Eric Lawrence
Telerik team
answered on 09 Sep 2015, 09:31 PM
If the goal is simply to have an easy way to turn on and off the behavior inside OnBeforeResponse, that's easy-- look at m_Hide304s in the script for an example of controlling the behavior using a menu item.

If you always want to return the same modified response, you don't need a script for that. Edit the response (either at a breakpoint or by using the "Unlock for Editing" command on the Web Session's context menu) then drag/drop the Session to Fiddler's AutoResponder tab to create a new rule that always plays back that response.

To always respond with a script, make a rule like:

MatchText: whatever 
Action: *script:DoMagic  


Save the rule. Click Rules > Customize Rules. Inside the Handlers class add the following code:
      
    static function DoMagic(oS: Session)
    {
        oS.utilCreateResponseAndBypassServer();
        oS.oResponse.headers.StatusDescription = "Magic!";
        oS.utilSetResponseBody("Some magic just happened to session #" + oS.id);
    }



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
0
Ravinder
Top achievements
Rank 1
answered on 21 Dec 2018, 08:45 AM
Fiddler log file generate the automatically using script 
Tags
Fiddler Classic
Asked by
Dominic
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Dominic
Top achievements
Rank 1
Ravinder
Top achievements
Rank 1
Share this question
or