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

Get Fiddler to properly read the response body

4 Answers 319 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
nasekt
Top achievements
Rank 1
nasekt asked on 14 Oct 2014, 11:19 AM
if (oSession.oResponse.headers.ExistsAndContains("Content-Type","html")){
oSession.utilDecodeResponse();
var oBodyString = oSession.GetResponseBodyAsString();
oSession["ui-color"]="yellow";
  var regex = /String/gi ;
if (!oSession.uriContains("google")){
if (regex.test(oBodyString)) {

  oSession.oRequest.FailSession(404, "Blocked", "Fiddler blocked the file");

}
}

}


Sometimes I have to refresh the page for it to work properly, Why is that? How to make it more foolproof ?

Thank you

4 Answers, 1 is accepted

Sort by
0
nasekt
Top achievements
Rank 1
answered on 14 Oct 2014, 11:21 AM
I aslo tried oBodyString = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);

no luck.
0
Eric Lawrence
Telerik team
answered on 14 Oct 2014, 04:47 PM
I'm afraid I don't understand your question.

You should use GetResponseBodyAsString() to get a response body as a string rather than just hoping that it is UTF-8. When you use GetREsponseBodyAsString(), you don't need to manually decode it first.

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
nasekt
Top achievements
Rank 1
answered on 14 Oct 2014, 11:40 PM
Basically,The above script says, if the target string is present in the <body>, then  block the page. So, here I am testing hundreds of HTML pages and sometimes, even though the "string" is present in the <body>, Fiddler does NOT block, why is that? (I have to refresh the page for it to block properly)
0
Eric Lawrence
Telerik team
answered on 16 Oct 2014, 04:32 PM
Unfortunately, I cannot perform psychic debugging without any details. If you can provide a SAZ file demonstrating the issue, I'm happy to have a look.

If not, my default assumption would be that the response is either different than you think, or the request didn't go to the network at all and was instead pulled from the local cache.


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
Fiddler Classic
Asked by
nasekt
Top achievements
Rank 1
Answers by
nasekt
Top achievements
Rank 1
Eric Lawrence
Telerik team
Share this question
or