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

Fiddlercore autoresponder issue

3 Answers 325 Views
Windows
This is a migrated thread and some comments may be shown as answers.
asia
Top achievements
Rank 1
asia asked on 02 Feb 2015, 09:00 PM
I want to make a c# console application for intercepting the https connection to a server and return a local xml file as responcemy code is Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
{
if (oS.url.Contains("test.com"))
{
oS.bBufferResponse = true;
oS.utilCreateResponseAndBypassServer();
}
};

Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS)
{
oS.utilDecodeResponse();
oS.LoadResponseFromFile("file.xml");
};
But it doesn't seem to work, I get connection error. Any ideas?

3 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 02 Feb 2015, 10:17 PM
You need to handle CONNECT tunnels specially.

See http://fiddler.wikidot.com/fiddlercore-autorespond

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
asia
Top achievements
Rank 1
answered on 13 Feb 2015, 01:28 PM
Thanks for the reply but i still dont get it.

your link contains this, assuming i understand the first part how do i replace the return a session with return a specific file ? can you give me a code example ? cheers

Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
{
if (oSession.HTTPMethodIs("CONNECT")) { oSession.oFlags["X-ReplyWithTunnel"] = "Fake for HTTPS Tunnel"; return; }
if (oS.uriContains("replaceme.txt"))
{
oS.utilCreateResponseAndBypassServer();
oS.responseBodyBytes = SessionIWantToReturn.responseBodyBytes;
oS.oResponse.headers = (HTTPResponseHeaders) SessionIWantToReturn.oResponse.headers.Clone();
}
};







0
Eric Lawrence
Telerik team
answered on 13 Feb 2015, 04:22 PM
There are several ways to achieve the task of returning a specific file. The simplest would be to set the oS.oFlags["x-replywithfile"] flag to the target filename.

Alternatively, you could manually fill responseBodyBytes and the oResponse.headers based on whatever you want.


Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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