• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Fiddler.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetHintsFromResponse

        private void GetHintsFromResponse(Session session)
        {
            session.utilDecodeResponse();

            var responseString = System.Text.Encoding.UTF8.GetString(session.ResponseBody);
            var regexStart = new Regex(@"^/\*\*/jQuery[0-9]{20}_[0-9]{10,15}\(");
            responseString = regexStart.Replace(responseString, string.Empty);
            var regexEnd = new Regex(@"\);$");
            responseString = regexEnd.Replace(responseString, string.Empty);

            try
            {
                var hintInfo = JsonConvert.DeserializeObject<DuoHint>(responseString);
                var hintString = string.Empty;
                foreach(var token in hintInfo.tokens.Where(t => t.hint_table != null).OrderBy(t => t.index))
                {
                    foreach(var row in token.hint_table.rows.Where(r => r.cells.Count > 0))
                    {
                        hintString += string.Join(", ", row.cells.Where(c => !string.IsNullOrEmpty(c.hint)).Select(c => c.hint.Trim()));
                        hintString += ", ";
                    }
                }

                _userControl.AppendText("\r\n" + hintString);
            }
            finally { }
        }
开发者ID:hmqcnoesy,项目名称:duoCheat,代码行数:27,代码来源:DuoCheater.cs


示例17: CONNECTTunnel

 private CONNECTTunnel(Session oSess, ClientPipe oFrom, ServerPipe oTo)
 {
     this._mySession = oSess;
     this.pipeTunnelClient = oFrom;
     this.pipeTunnelRemote = oTo;
     this._mySession.SetBitFlag(SessionFlags.IsBlindTunnel, true);
 }
开发者ID:pisceanfoot,项目名称:socketproxy,代码行数:7,代码来源:CONNECTTunnel.cs


示例18: GetAnswersFromResponse

        private void GetAnswersFromResponse(Session session)
        {
            session.utilDecodeResponse();

            var responseString = System.Text.Encoding.UTF8.GetString(session.ResponseBody);

            try
            {
                var cheatInfo = JsonConvert.DeserializeObject<CheatInfo>(responseString);
                if (cheatInfo.session_elements.Count == 0) return;

                _userControl.AppendText(string.Empty);
                _userControl.ResetCount();

                foreach (var element in cheatInfo.session_elements)
                {
                    if (element.form_tokens.Count(t => t.options.Count > 0) > 0) _userControl.AppendText(element.form_tokens.First(f => f.options.Count > 0).options.First(o => o.correct).display_value);
                    else if (element.options.Count > 0) _userControl.AppendText(string.Join(" / ", element.options.Where(o => o.correct).Select(o => o.sentence)));
                    else if (!string.IsNullOrEmpty(element.translation)) _userControl.AppendText(element.translation);
                    else if (!string.IsNullOrEmpty(element.text)) _userControl.AppendText(element.text);
                    else if (element.correct_solutions.Count > 0) _userControl.AppendText(element.correct_solutions[0]);
                    else _userControl.AppendText(string.Empty);
                }
            }
            finally
            {
            }
        }
开发者ID:hmqcnoesy,项目名称:duoCheat,代码行数:28,代码来源:DuoCheater.cs


示例19: _AfterComplete

        static void _AfterComplete(Session oSession)
        {
            if (!Settings.Current.CacheEnabled) return;
            if (!_Filter(oSession)) return;

            //服务器返回200,下载新的文件
            if (oSession.responseCode == 200)
            {
                string filepath = TaskRecord.GetAndRemove(oSession.fullUrl);

                //只有TaskRecord中有记录的文件才是验证的文件,才需要保存
                if (!string.IsNullOrEmpty(filepath))
                {
                    if (File.Exists(filepath))
                        File.Delete(filepath);

                    //保存下载文件并记录Modified-Time
                    try
                    {
                        oSession.SaveResponseBody(filepath);
                        //cache.RecordNewModifiedTime(oSession.fullUrl,
                        //	oSession.oResponse.headers["Last-Modified"]);
                        _SaveModifiedTime(filepath, oSession.oResponse.headers["Last-Modified"]);
                        //Debug.WriteLine("CACHR> 【下载文件】" + oSession.PathAndQuery);
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(oSession, ex, "会话结束时,保存返回文件时发生异常");
                    }
                }
            }
        }
开发者ID:a0902031845,项目名称:KanColleCacher,代码行数:32,代码来源:FiddlerRules.cs


示例20: FilterAndInject

        public void FilterAndInject(Session oSession)
        {
            Debug.Log("FilterAndInject: MatchRule check!" + oSession.fullUrl);
            // response content type is text/html
            if (bGlobalEnabled && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html"))
            {
                Debug.Log("FilterAndInject: MatchRule check!");
                // request url is match the user's config rules
                if(this.MatchRule(oSession))
                {
                    oSession.utilDecodeResponse();
                    oSession.utilReplaceOnceInResponse(@"<head>", @"<head><script>" + sScriptText + "</script>", false);

                    // script tag add crossorigin 
                    oSession.utilReplaceInResponse(@"<script", @"<script crossorigin ");

                    oSession.oResponse.headers["Cache-Control"] = "no-cache";
                    oSession.oResponse.headers["Content-Length"] = oSession.responseBodyBytes.Length.ToString();
                }
            }

           // javascript request, add cross domain header
           if (oSession.fullUrl.Contains(".js"))
           {
               if (oSession.oResponse.headers["Access-Control-Allow-Origin"] == "")
               {
                   oSession.oResponse.headers["Access-Control-Allow-Origin"] = "*";
               }
           }
        }
开发者ID:modulexcite,项目名称:Rosin,代码行数:30,代码来源:Injection.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FileHelpers.LineInfo类代码示例发布时间:2022-05-24
下一篇:
C# FernBusinessBase.IDRequest类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap