fiddler请求转发配置

Fiddler脚本修改

OnBeforeRequest方法增加请求转发代码

  for(var i:int=0; i<route_rules.length; i++){
            var mock_service_name=route_rules[i].mockServiceName;
            var match_urls=route_rules[i].urls;
            for(var j:int=0; j<match_urls.length; j++){
                var match_url=match_urls[j];
                if(oSession.uriContains(match_url)){
                    FiddlerApplication.Log.LogFormat("hit the mock rule [{0}: {1}], currentRequest: {2}", mock_service_name, match_url, oSession.url);
                    oSession.oRequest.headers.Add("mockServiceName", mock_service_name);
                    oSession.oRequest.headers.UriScheme = "http";
                    oSession.hostname="mock-server.com";
                    break;   
                }
            }
        }

顶部增加规则配置代码

 public static var route_rules=[
        {
            "mockServiceName":"aaatest",
            "urls":["/cloudst/mock/v1/page"]
        },
        {
        "mockServiceName":"xxxxx",
            "urls":["/cloest/mock/api/get"]
        }
     ];
发表评论 / Comment

提示:本文章评论功能已关闭