How do I use Fiddler to modify the status code in an HTTP response?

后端 未结 3 1164
北恋
北恋 2021-01-30 05:22

I need to test some client application code I\'ve written to test its\' handling of various status codes returned in an HTTP response from a web server.

I have Fiddler 2

3条回答
  •  佛祖请我去吃肉
    2021-01-30 05:51

    Create a FiddlerScript rule. Here's what I used in order to generate a local copy of a website that was intentionally using 403 on every page to thwart HTTrack/WGET. https://gist.github.com/JamoCA/22db8d68a9a2fb20cb04a85360185333

    /* 20180615 Fiddler rule to ignore all 403 HTTP Status errors so WGET or HTTrack can generate local copy of remote website */
       SCENARIO: Changing the user agent or setting a delay isn't enough and the entire remote server is configured to respond w/403.
       CONFIGURE: Add below rule to FiddlerScript OnBeforeReponse() section.  Configure HTTrack/WGET/CRON to use proxy 127.0.0.01:8888 */
    
    static function OnBeforeResponse(oSession: Session) {
      if (oSession.HostnameIs("TARGETHOSTNAME_FILTER.com") && oSession.responseCode == 403) {
        oSession.responseCode = 200;
        oSession.oResponse.headers.HTTPResponseCode = 200;
        oSession.oResponse.headers.HTTPResponseStatus = "200 OK";
      }
    }
    

提交回复
热议问题