예제 #1
0
        void FiddlerApplication_BeforeRequest(FiddlerSession rpSession)
        {
            var rStopwatch = Stopwatch.StartNew();

            if (EnableUpstreamProxy)
                rpSession["x-OverrideGateway"] = UpstreamProxy;

            var rRequest = rpSession.oRequest;
            var rPath = rpSession.PathAndQuery;
            var rIsGame = rPath.StartsWith("/kcs");
            var rIsResource = rPath.StartsWith("/kcs/") && !rPath.StartsWith("/kcs/mainD2.swf");

            if (rPath.Contains("/kcs/mainD2.swf"))
                GameToken(rpSession.fullUrl);

            Session rSession;
            if (!rIsGame)
                rSession = new Session(rpSession.fullUrl);
            else if (rIsResource)
            {
                var rResourceSession = new ResourceSession(rpSession.fullUrl, rpSession.PathAndQuery.Substring(1));
                rSession = rResourceSession;

                LoadFromCache(rpSession, rResourceSession);
            }
            else
            {
                var rUrl = rpSession.PathAndQuery;
                var rPosition = rUrl.IndexOf("/kcsapi/");
                if (rPosition != -1)
                    rUrl = rUrl.Substring(rPosition + 8);
                rSession = new ApiSession(rpSession.fullUrl, rUrl) { RequestBody = Uri.UnescapeDataString(rpSession.GetRequestBodyAsString()) };
            }

            rpSession.Tag = rSession;

            rSession.Stopwatch = rStopwatch;
            if (rSession.Status != SessionStatus.LoadedFromCache)
                rSession.Status = SessionStatus.Request;

            NewSession(rSession);

            Debug.WriteLine("Request - " + rpSession.fullUrl);
        }
예제 #2
0
        static void ProcessSessionCore(ApiSession rpSession)
        {
            var rApi = rpSession.Url;
            var rRequestBody = rpSession.RequestBody;
            var rContent = rpSession.ResponseString.Replace("svdata=", string.Empty);

            HashSet<ApiParserBase> rParsers;
            if (!rContent.IsNullOrEmpty() && !rContent.StartsWith("[Fiddler]") && r_Parsers.TryGetValue(rApi, out rParsers))
            {
                Dictionary<string, string> rRequests = null;
                if (!rRequestBody.IsNullOrEmpty() && rRequestBody.Contains('&'))
                    rRequests = rRequestBody.Split('&').Where(r => r.Length > 0).Select(r => r.Split('='))
                        .ToDictionary(r => Uri.UnescapeDataString(r[0]), r => Uri.UnescapeDataString(r[1]));

                var rJson = JObject.Parse(rContent);

                foreach (var rParser in rParsers)
                {
                    rParser.Request = rRequests;
                    rParser.Path = rApi;
                    rParser.Process(rJson);
                }
            }
        }
예제 #3
0
 public static void Post(ApiSession rpSession)
 {
     r_Block.Post(rpSession);
 }