当前位置: 首页>>代码示例>>C#>>正文


C# Fiddler.Session类代码示例

本文整理汇总了C#中Fiddler.Session的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Session类属于Fiddler命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRequestFromSession

 public static HttpRequestMessage CreateRequestFromSession(Session session)
 {
     var request = new HttpRequestMessage
     {
         RequestUri = new Uri(session.fullUrl, UriKind.RelativeOrAbsolute),
         Method = new HttpMethod(session.RequestMethod)
     };
     var failedHeaders = new List<HTTPHeaderItem>();
     foreach (var header in session.oRequest.headers)
     {
         if (!request.Headers.TryAddWithoutValidation(header.Name, header.Value))
         {
             failedHeaders.Add(header);
         }
     }
     if (session.RequestBody.Length > 0)
     {
         request.Content = new ByteArrayContent(session.RequestBody);
         foreach (var header in failedHeaders)
         {
             request.Content.Headers.TryAddWithoutValidation(header.Name, header.Value);
         }
     }
     return request;
 }
开发者ID:modulexcite,项目名称:fiddler-extension,代码行数:25,代码来源:FiddlerMessageBuilder.cs

示例2: FiddlerApplication_BeforeRequest

        static void FiddlerApplication_BeforeRequest(Session rpSession)
        {
            if (Preference.Current.Network.UpstreamProxy.Enabled)
                rpSession["x-OverrideGateway"] = Preference.Current.Network.UpstreamProxy.Address;

            var rRequest = rpSession.oRequest;

            var rFullUrl = rpSession.fullUrl;
            var rPath = rpSession.PathAndQuery;

            NetworkSession rSession;
            if (rPath.StartsWith("/kcsapi/"))
                rSession = new ApiSession(rFullUrl);
            else if (rPath.StartsWith("/kcs/") || rPath.StartsWith("/gadget/"))
                rSession = new ResourceSession(rFullUrl, rPath);
            else
                rSession = new NetworkSession(rFullUrl);

            rSession.RequestBodyString = Uri.UnescapeDataString(rpSession.GetRequestBodyAsString());

            rpSession.Tag = rSession;

            SessionSubject.OnNext(rSession);

            if (rFullUrl == GameConstants.GamePageUrl || rPath == "/gadget/js/kcs_flash.js")
                rpSession.bBufferResponse = true;

            var rResourceSession = rSession as ResourceSession;
            if (rResourceSession != null)
                CacheService.Instance.ProcessRequest(rResourceSession, rpSession);
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun-Fx4,代码行数:31,代码来源:KanColleProxy.cs

示例3: AutoTamperRequestBefore

 public void AutoTamperRequestBefore(Session oSession)
 {
     if (cacheController != null)
     {
         cacheController.Filter(oSession);
     }
 }
开发者ID:SunboX,项目名称:Easygoing.FiddlerCache,代码行数:7,代码来源:FiddlerPlugin.cs

示例4: FiddlerApplication_BeforeRequest

 void FiddlerApplication_BeforeRequest(Session oSession)
 {
     if (oSession.LocalProcess.ToLower().Contains("skypebot2"))
     {
         oSession.Ignore();
     }
 }
开发者ID:KanColleSoftFan,项目名称:KKLBot,代码行数:7,代码来源:KanColleProxy.cs

示例5: _BeforeRequest

        //This event fires when a client request is received by Fiddler
        static void _BeforeRequest(Session oSession)
        {
            if (!Settings.Current.CacheEnabled) return;
			if (!_Filter(oSession)) return;

            string filepath;
			var direction = cache.GotNewRequest(oSession.fullUrl, out filepath);
			
			if (direction == Direction.Return_LocalFile)
			{
				//返回本地文件
				oSession.utilCreateResponseAndBypassServer();
				oSession.ResponseBody = File.ReadAllBytes(filepath);
				_CreateResponseHeader(oSession, filepath);

				//Debug.WriteLine("CACHR> 【返回本地】" + filepath);
			}
			else if (direction == Direction.Verify_LocalFile)
			{
				//请求服务器验证文件
				//oSession.oRequest.headers["If-Modified-Since"] = result;
				oSession.oRequest.headers["If-Modified-Since"] = _GetModifiedTime(filepath);
				oSession.bBufferResponse = true;

				//Debug.WriteLine("CACHR> 【验证文件】" + oSession.PathAndQuery);
			}
			else 
			{ 
				//下载文件
			}
        }
开发者ID:lskstc,项目名称:KanColleCacher,代码行数:32,代码来源:FiddlerRules.cs

示例6: Export

        public static Entry Export(Session session, bool requestOnly = false)
        {
            var entry = new Entry();
            entry.startedDateTime = session.Timers.ClientBeginRequest.ToString("o");
            entry.request = GetRequest(session);
            if (!requestOnly)
            {
                entry.response = GetResponse(session);
            }

            entry.timings = GetTimings(session.Timers);
            entry.comment = session["ui-comments"];

            entry.time = GetTotalTime(entry.timings);

            if (
                !string.IsNullOrEmpty(session["ui-comments"])
                // <-- not sure if this is correct, maybe a typo or missing assignation in BasicFormats?
                && !session.isFlagSet(SessionFlags.SentToGateway))
            {
                entry.serverIPAddress = session.m_hostIP;
            }
            entry.connection = session.clientPort.ToString(CultureInfo.InvariantCulture);
            return entry;
        }
开发者ID:bitpusher,项目名称:mocument,代码行数:25,代码来源:HttpArchiveTranscoder.cs

示例7: FiddlerApplication_BeforeResponse

        void FiddlerApplication_BeforeResponse(FiddlerSession rpSession)
        {
            var rSession = rpSession.Tag as Session;
            if (rSession != null)
            {
                if (rSession.Status == SessionStatus.Request)
                    rSession.Status = SessionStatus.Responsed;

                var rApiSession = rSession as ApiSession;
                if (rApiSession != null)
                {
                    rApiSession.ResponseString = rpSession.GetResponseBodyAsString();
                    ApiParsers.Post(rApiSession);
                }

                var rResourceSession = rSession as ResourceSession;
                if (rResourceSession != null && ResourceCache.IsEnabled && rpSession.responseCode == 200 && !File.Exists(rResourceSession.CachePath) && rpSession.oResponse["Last-Modified"] != null)
                {
                    rResourceSession.Data = rpSession.ResponseBody;
                    rResourceSession.LastModifiedTime = Convert.ToDateTime(rpSession.oResponse["Last-Modified"]);
                    ResourceCache.SaveFile(rResourceSession);
                }

                if (rSession.Url.Contains("kcs/sound/titlecall/") || rSession.Url.Contains("api_start2"))
                    KanColleGame.Current.RaiseGameLaunchedEvent();
            }

            Debug.WriteLine("Response - " + rpSession.fullUrl);
        }
开发者ID:XHidamariSketchX,项目名称:ProjectDentan,代码行数:29,代码来源:GameProxy.cs

示例8: ExportSessions

        public bool ExportSessions(string sFormat, Session[] oSessions, Dictionary<string, object> dictOptions,
                                    EventHandler<ProgressCallbackEventArgs> evtProgressNotifications)
        {
            bool bResult = true;
            string sFilename = null;

            // [3] Ask the Fiddler GUI to obtain the filename to export to
            sFilename = Fiddler.Utilities.ObtainSaveFilename("Export As " + sFormat, "JMeter Files (*.jmx)|*.jmx");

            if (String.IsNullOrEmpty(sFilename)) return false;

            if (!Path.HasExtension(sFilename)) sFilename = sFilename + ".jmx";

            try
            {

                Encoding encUTF8NoBOM = new UTF8Encoding(false);
                JMeterTestPlan jMeterTestPlan = new JMeterTestPlan(oSessions, sFilename);
                System.IO.StreamWriter sw = new StreamWriter(sFilename, false, encUTF8NoBOM);
                sw.Write(jMeterTestPlan.getJmx());
                sw.Close();
            }
            catch (Exception eX)
            {
                Fiddler.FiddlerApplication.Log.LogString(eX.Message);
                Fiddler.FiddlerApplication.Log.LogString(eX.StackTrace);
                bResult = false;
            }
            return bResult;
        }
开发者ID:gtyd,项目名称:FiddlerExtend,代码行数:30,代码来源:JMeterExporter.cs

示例9: AutoTamperRequestBefore

        public void AutoTamperRequestBefore(Session oSession)
        {
            if (model.Enabled)
            {
                //  if (m_SimulateModem) {
                //    // Delay sends by 300ms per KB uploaded.
                //    oSession["request-trickle-delay"] = "30";
                //    // Delay receives by 150ms per KB downloaded.
                //    oSession["response-trickle-delay"] = "150";
                //}

                int requestDelay = SpeedConvert.covert(model.RequestDelaySpeed);
               int  reponseDelay = SpeedConvert.covert(model.ReponseDelaySpeed);

               oSession["request-trickle-delay"] = Convert.ToString(requestDelay);
               oSession["response-trickle-delay"] = Convert.ToString(reponseDelay);
            }
            else
            {
                oSession["request-trickle-delay"] = null;
                oSession["response-trickle-delay"] = null;
            }

               // oSession.oRequest["User-Agent"] = sUserAgent;
        }
开发者ID:superproxy,项目名称:SpeedLimit4Fiddler,代码行数:25,代码来源:SpeedLimit4Fiddler.cs

示例10: InspectSession

        private void InspectSession(Session[] sessions)
        {
            var session = sessions[0];
            var requestBody = session.GetRequestBodyAsString();
            var responseBody = session.GetResponseBodyAsString();
            var requestHeaders = GetHeaders(session.RequestHeaders);

            var timers = session.Timers;
            var sessionTime = timers.ClientDoneResponse - timers.ClientBeginRequest;

            try
            {
                var inspector = new Inspector(requestBody, responseBody, requestHeaders, sessionTime);
                var actions = inspector.GetActionsData();
                var requestData = inspector.GetRequestData();
                var responseData = inspector.GetResponseData();

                RequestViewModel.Actions = new ObservableCollection<ActionBase>(actions);
                RequestViewModel.ErrorInfo = responseData.ErrorInfo;
                RequestInfoViewModel.SetSessionData(requestData, responseData, sessionTime, session.RequestBody.Length, session.ResponseBody.Length);
            }
            catch
            {
                RequestViewModel.Actions = new ObservableCollection<ActionBase>();
                RequestInfoViewModel.ClearSessionData();
            }
        }
开发者ID:dstarkowski,项目名称:csom-inspector,代码行数:27,代码来源:InspectorPresenter.cs

示例11: AutoTamperRequestBefore

        public void AutoTamperRequestBefore(Session oSession)
        {
            // Check that our plugin has been enabled
            if (authTab.IsEnabled == false)
            {
                return;
            }

            // Clone our existing request
            HTTPRequestHeaders oNewHeaders = oSession.oRequest.headers.Clone() as HTTPRequestHeaders;
            byte[] requestBody = oSession.requestBodyBytes;

            // Look for any configuration data values to remove
            FiddlerApplication.Log.LogString(String.Format("COOKIE: {0}", oNewHeaders["Cookie"]));

            // Check that we haven't already sent a modified response
            if (!oSession.oFlags.ContainsKey("repeat-request"))
            {
                if (StripSessionFromRequest(oNewHeaders, ref requestBody))
                {
                    // Add our tracking flag
                    StringDictionary flags = new StringDictionary();
                    flags.Add("repeat-request", "true");
                    FiddlerApplication.oProxy.InjectCustomRequest(oNewHeaders, requestBody, flags);
                }
            }
        }
开发者ID:xpn,项目名称:FiddlerCRAPlugin,代码行数:27,代码来源:CheckRequiredAuthPlugin.cs

示例12: FiddlerApplication_BeforeResponse

        static void FiddlerApplication_BeforeResponse(Session oSession)
        {
            string url = oSession.url;
            DateTime start = oSession.Timers.ClientBeginRequest;
            DateTime end = oSession.Timers.ClientDoneResponse;
            TimeSpan t = end - start;

            if (oSession.host != filter)
                return;

            if(oSession.Timers.DNSTime > 0)
                Console.WriteLine("DNS TIME: {0}", oSession.Timers.DNSTime);

            if (!sdata.Keys.Contains(url))
                sdata[url] = new List<RequestAggregate>();

            RequestAggregate rq = new RequestAggregate()
            {
                data_size = oSession.GetResponseBodyAsString().Length,
                host = oSession.host,
                time = t.TotalMilliseconds
            };

            Monitor.Enter(sdata[url]);
            sdata[url].Add(rq);
            Monitor.Exit(sdata[url]);

            ConsoleColor c = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.DarkRed;
            Console.WriteLine("{0}  ==> {1}", oSession.url, end-start);
            Console.ForegroundColor = defaultColor;
        }
开发者ID:beersbr,项目名称:FiddlerTrafficConsumer,代码行数:32,代码来源:Program.cs

示例13: FiddlerApplication_BeforeRequest

 static void FiddlerApplication_BeforeRequest(Session oSession)
 {
     ConsoleColor c = Console.ForegroundColor;
     Console.ForegroundColor = ConsoleColor.DarkGreen;
     Console.WriteLine("{0}", oSession.url);
     Console.ForegroundColor = defaultColor;
 }
开发者ID:beersbr,项目名称:FiddlerTrafficConsumer,代码行数:7,代码来源:Program.cs

示例14: CreateResponseFromSession

        public static HttpResponseMessage CreateResponseFromSession(Session session)
        {
            var response = new HttpResponseMessage
            {
                StatusCode = (HttpStatusCode)session.responseCode
            };
            var failedHeaders = new List<HTTPHeaderItem>();
            foreach (var header in session.oResponse.headers)
            {
                if (!response.Headers.TryAddWithoutValidation(header.Name, header.Value))
                {
                    failedHeaders.Add(header);
                }
            }

            if (session.ResponseBody.Length > 0)
            {
                response.Content = new ByteArrayContent(session.ResponseBody);
                foreach (var header in failedHeaders)
                {
                    response.Content.Headers.TryAddWithoutValidation(header.Name, header.Value);
                }
            }
            return response;
        }
开发者ID:modulexcite,项目名称:fiddler-extension,代码行数:25,代码来源:FiddlerMessageBuilder.cs

示例15: Handle

        public override void Handle(Session Session)
        {
            GameState state = FFRKProxy.Instance.GameState;
            // Win or lose, finishing a battle means it's safe to record that encounter and its drops
            // since it won't be possible for the user to have the same drop set if they continue.
            if (state.ActiveBattle != null)
            {
                EventBattleInitiated original_battle = state.ActiveBattle;
                state.ActiveBattle = null;

                lock (FFRKProxy.Instance.Cache.SyncRoot)
                {
                    DataCache.Battles.Key key = new DataCache.Battles.Key { BattleId = original_battle.Battle.BattleId };
                    DataCache.Battles.Data data = null;
                    if (FFRKProxy.Instance.Cache.Battles.TryGetValue(key, out data))
                    {
                        data.Samples++;
                        data.HistoSamples++;
                    }
                }

                DbOpRecordBattleEncounter op = new DbOpRecordBattleEncounter(original_battle);
                FFRKProxy.Instance.Database.BeginExecuteRequest(op);
                FFRKProxy.Instance.RaiseBattleComplete(original_battle);
            }
        }
开发者ID:JulianoW,项目名称:ffrkx,代码行数:26,代码来源:HandleCompleteBattle.cs


注:本文中的Fiddler.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。