fidder 修改请求响应的2种方法

    static function OnPeekAtResponseHeaders(oSession: Session) {
        //FiddlerApplication.Log.LogFormat("Session {0}: Response header peek shows status is {1}", oSession.id, oSession.responseCode);
        if (m_DisableCaching) {
            oSession.oResponse.headers.Remove("Expires");
            oSession.oResponse["Cache-Control"] = "no-cache";
        }

        if ((bpStatus>0) && (oSession.responseCode == bpStatus)) {
            oSession["x-breakresponse"]="status";
            oSession.bBufferResponse = true;
        }
        
        if ((null!=bpResponseURI) && oSession.uriContains(bpResponseURI)) {
            oSession["x-breakresponse"]="uri";
            oSession.bBufferResponse = true;
        }
        if (oSession.HostnameIs("lozn.free.idcfengye.com")){ 
            // && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
            oSession.bBufferResponse = true;    //需要在返回头这里就设置buffer处理,否则,后续无法在onBeforeResponse中修改body(修改的动作不会阻塞原来的返回)
        }

    } 

    static function OnBeforeResponse(oSession: Session) {
        if (m_Hide304s && oSession.responseCode == 304) {
            oSession["ui-hide"] = "true";
        }
     
        if (oSession.HostnameIs("lozn.free.idcfengye.com") && oSession.oResponse.headers.ExistsAndContains("Server","Kestrel")){
            oSession.utilDecodeResponse();

           oSession.utilReplaceInResponse("code","code\"=1,\"before");

          oSession.utilReplaceInResponse('Content-Security-Policy','');

        }
    }

方法2

Fiddler-> Rules-> Automatic Breakpoints,点击【Before Responses】。

你可能感兴趣的:(fidder 修改请求响应的2种方法)