Hello StackOverflow Folks,
I'm new to Fiddler 2, but I seem to be getting along with it pretty good. Although I have one problem that I can't seem to solve.
What I want to do is actually very simple I think. I want to intercept a request, let it run, but if the response doesn't suit me I want it to resend the request and make the initial request nonexcistent. This using FiddlerScript.
Why is this useful: in cases where you send a request but the response is different everytime. and you just want the right kind of response.
What I have so far:
static function OnBeforeResponse(oSession: Session)
{
if (oSession.uriContains("/stackoverflowexample"))
{
if(oSession.GetRequestBodyAsString().Contains("GetRandomItem"))
{
if(oSession.GetResponseBodyAsString().ToString().Contains("ItemID"))
{
var body = oSession.GetResponseBodyAsString();
var item = 0;
for(var i = 0; i< body.Length; i++)
{
if(i < body.Length -7)
{
if(body.Substring(i, 6) == "ItemID")
{
item= Convert.ToInt32(body.Substring(i+7,1));
}
}
}
MessageBox.Show(item.ToString());
if(item < 2536) //for example itemid must be higher than 2536
{
//STOP / MAKE this session nonexcistent
//RESEND CURRENT REQUEST to get new response
oSession.state = SessionStates.SendingRequest;
FiddlerObject.utilIssueRequest(oSession.oRequest.ToString());
}
}
}
}
}
Every possible solution using Fiddlerscript is welcome.
Thank you Stackoverflow cummunity! (and Fiddler developers)