Get Fiddler to properly read the response body

5 posts, 0 answers
  1. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 14 Oct 2014 Link to this post

    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
  2. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 14 Oct 2014 in reply to nasekt Link to this post

    I aslo tried oBodyString = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);

    no luck.
  3. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 14 Oct 2014 Link to this post

    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.

     
  4. nasekt
    nasekt avatar
    40 posts
    Member since:
    Aug 2014

    Posted 14 Oct 2014 in reply to Eric Lawrence Link to this post

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

    Posted 16 Oct 2014 Link to this post

    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.

     
Back to Top