Fiddler - 拦截请求返回不同的响应

时间:2016-09-22 14:20:19

标签: fiddler jscript

在Fiddler中我有一些自定义规则,当从服务器获得某个响应时,它会自动发出一个新请求:

static function OnBeforeResponse(oSession: Session) {
    ...
    if (oSession.uriContains("something.aspx")) {

        var requestB = "..."
        FiddlerObject.utilIssueRequest(requestB);
    }
...
}

我想拦截来自客户端的requestA,等到我收到requestB的响应,然后返回requestB对requestA的响应。有谁知道如何实现这个目标?

1 个答案:

答案 0 :(得分:0)

您可能想尝试这样的函数FiddlerApplication.oProxy.SendRequestAndWait

static function OnBeforeResponse(oSession: Session) 

{
...
    if (oSession.uriContains("something.aspx"))
   {
        var oSD = new System.Collections.Specialized.StringDictionary();
        var GetResquestBAnswer : Session = FiddlerApplication.oProxy.SendRequestAndWait(RequestB.oRequest.headers, RequestB.requestBodyBytes, oSD, null);
        if (200 == GetResquestBAnswer.responseCode)
        {
           oSession.ResponseBody=GetResquestBAnswer.ResponseBody;
        }
    } 
...
}