Ejemplo n.º 1
0
        private void FiddlerApplication_BeforeRequest(Fiddler.Session oSession)
        {
            Utility.Configuration.ConfigurationData.ConfigConnection c = Utility.Configuration.Config.Connection;


            // 上流プロキシ設定
            if (c.UseUpstreamProxy)
            {
                oSession["X-OverrideGateway"] = string.Format("localhost:{0}", c.UpstreamProxyPort);
            }


            if (oSession.fullUrl.Contains("/kcsapi/"))
            {
                string url  = oSession.fullUrl;
                string body = oSession.GetRequestBodyAsString();

                //保存
                {
                    if (c.SaveReceivedData && c.SaveRequest)
                    {
                        Task.Run((Action)(() => {
                            SaveRequest(url, body);
                        }));
                    }
                }

                UIControl.BeginInvoke((Action)(() => { LoadRequest(url, body); }));
            }
        }
Ejemplo n.º 2
0
        private void FiddlerApplication_BeforeRequest(Fiddler.Session oSession)
        {
            Utility.Configuration.ConfigurationData.ConfigConnection c = Utility.Configuration.Config.Connection;


            // 上流プロキシ設定
            if (c.UseUpstreamProxy)
            {
                oSession["X-OverrideGateway"] = string.Format("{0}:{1}", c.UpstreamProxyAddress, c.UpstreamProxyPort);
            }


            if (oSession.fullUrl.Contains("/kcsapi/"))
            {
                string url  = oSession.fullUrl;
                string body = oSession.GetRequestBodyAsString();

                //保存
                {
                    if (c.SaveReceivedData && c.SaveRequest)
                    {
                        Task.Run((Action)(() => {
                            SaveRequest(url, body);
                        }));
                    }
                }

                UIControl.BeginInvoke((Action)(() => { LoadRequest(url, body); }));
            }

            // flash wmode & quality
            {
                if (oSession.fullUrl.Contains("/gadget/js/kcs_flash.js"))
                {
                    oSession.bBufferResponse = true;
                }
            }
        }
Ejemplo n.º 3
0
        public void SetModificSession(Fiddler.Session session)
        {
            ChangeEditRuleMode(RuleEditMode.NewRuleMode, null, null);
            tb_urlFilter.Text          = session.fullUrl;
            cb_macthMode.SelectedIndex = 2;

            pictureBox_editHttpFilter.Tag = GetHttpFilter();
            if (tabControl_Modific.SelectedIndex == 0)
            {
                tabControl_Modific.SelectedIndex = 1;
            }
            else if (tabControl_Modific.SelectedIndex == 2)
            {
                tabControl_Modific.SelectedIndex = 3;
            }

            //Request Replace
            tb_requestReplace_uri.Text = session.fullUrl;
            cb_editRequestEdition.Text = ((Fiddler.HTTPHeaders)(session.oRequest.headers)).HTTPVersion;
            cb_editRequestMethod.Text  = session.RequestMethod;
            elv_requsetReplace.ListDataView.Items.Clear();
            foreach (var tempHead in session.RequestHeaders)
            {
                elv_requsetReplace.ListDataView.Items.Add(String.Format("{0}: {1}", tempHead.Name, tempHead.Value));
            }
            rtb_requsetReplace_body.Clear();
            if (session.requestBodyBytes != null)
            {
                if (session.requestBodyBytes.Length > 0)
                {
                    //Encoding tempRequestEncoding = session.GetRequestBodyEncoding() == null ? Encoding.UTF8 : session.GetRequestBodyEncoding();
                    //rtb_requsetReplace_body.Text = tempRequestEncoding.GetString(session.requestBodyBytes);
                    rtb_requsetReplace_body.Text = session.GetRequestBodyAsString();
                }
            }
            MemoryStream tempRequestStream = new MemoryStream();

            if (session.WriteRequestToStream(false, true, true, tempRequestStream))
            {
                byte[] tempRequestBytes = new byte[tempRequestStream.Length];
                tempRequestBytes = tempRequestStream.ToArray();
                //tempRequestStream.ReadAsync(tempRequestBytes, 0, (int)tempRequestStream.Length);
                //tempRequestStream.Position=0;
                //tempRequestStream.Read(tempRequestBytes, 0, (int)tempRequestStream.Length);
                rtb_requestRaw.Clear();
                rtb_requestRaw.Text = Encoding.UTF8.GetString(tempRequestBytes);
            }
            else
            {
                rtb_requestRaw.Clear();
                rtb_requestRaw.Text = "read RequestStream fail";
            }
            tempRequestStream.Close();

            //Response Replace

            MemoryStream tempReponseStream = new MemoryStream();

            if (session.WriteResponseToStream(tempReponseStream, false))
            {
                byte[] tempResponseBytes = new byte[tempReponseStream.Length];
                tempResponseBytes = tempReponseStream.ToArray();
                rawResponseEdit.SetText(Encoding.UTF8.GetString(tempResponseBytes));
            }
            else
            {
                rawResponseEdit.SetText("read ResponseStream fail");
            }
            tempReponseStream.Close();
        }