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


C# Session.utilSetResponseBody方法代码示例

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


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

示例1: FiddlerApplication_BeforeResponse

        private void FiddlerApplication_BeforeResponse(Session oSession)
        {
            if (!set.CacheEnabled) return;

            if (oSession.PathAndQuery.StartsWith("/kcsapi/api_start2") && Settings.Current.HackEnabled)
            {
                jsonData = oSession.GetResponseBodyAsString();
                ModifyData.Items.ForEach(x => setModifiedData(x));
                oSession.utilSetResponseBody(jsonData);
            }
        }
开发者ID:hakuame,项目名称:KanColleCacher,代码行数:11,代码来源:GraphModifier.cs

示例2: BeforeRequest

        public static void BeforeRequest(Session oS)
        {
            var file = oS.url.Replace('/', '_').Split('?').First();
            var method = oS.HTTPMethodIs("GET") ? "GET"
                             : oS.HTTPMethodIs("POST") ? "POST"
                                   : oS.HTTPMethodIs("PUT") ? "PUT" : null;
            oS.utilCreateResponseAndBypassServer();
            var lines = File.ReadAllLines("./Api/Data/" + method + " " + file + ".txt");
            oS.oResponse.headers = Parser.ParseResponse(lines.First());
            oS.oResponse.headers.Add("Content-Type", "application/json");

            oS.utilSetResponseBody(String.Join(Environment.NewLine, lines.Skip(2).ToArray()));
        }
开发者ID:peterrow,项目名称:gocardless-dotnet,代码行数:13,代码来源:FiddlerSetupFixture.cs

示例3: AutoTamperResponseBefore

        public void AutoTamperResponseBefore(Session oSession)
        {
            if (oSession.uriContains("luoqi/fun/option.php"))
            {
                string xx = oSession.url;
                string[] requestPar = xx.Split(new char[2] {'?','&'});

                foreach (string i in requestPar)
                {
                    if(i.ToString().Contains("guid="))
                    {
                        guid = i.ToString().Substring(i.ToString().IndexOf("=") + 1);
                    }
                }
                oSession.utilSetResponseBody("irv=200|sign=" + this.Sign(oSession, prize.Text, guid) + "|couponw=asdafas" + "|prize=" + prize.Text);
            }
        }
开发者ID:zhang1987wing,项目名称:FiddlerResponse,代码行数:17,代码来源:Main.cs

示例4: FiddlerApplication_BeforeRequest

        private void FiddlerApplication_BeforeRequest(Session oSession)
        {
            if (!set.CacheEnabled) return;

            if (oSession.PathAndQuery.StartsWith("/kcsapi/api_req_furniture/music_play") && set.HackMusicRequestEnabled)
            {
                oSession.utilCreateResponseAndBypassServer();
                oSession.oResponse.headers.Add("Content-Type", "text/plain");
                oSession.utilSetResponseBody(@"svdata={""api_result"":1,""api_result_msg"":""\u6210\u529f"",""api_data"":{""api_coin"":" + fcoin.ToString() + @"}}");
            }
            else if (oSession.PathAndQuery.StartsWith("/kcsapi/api_get_member/picture_book") && set.HackBookEnabled)
            {
                oSession.utilCreateResponseAndBypassServer();
                oSession.oResponse.headers.Add("Content-Type", "text/plain");

                int type = 1; // 1: 舰娘图鉴, 2: 装备图鉴
                int no = 1;   // 页数
                var param = oSession.GetRequestBodyAsString().Split('&');
                foreach (var p in param)
                {
                    var kv = p.Split('=');
                    if (kv[0] == "api%5Ftype")
                    {
                        type = int.Parse(kv[1]);
                    }
                    else if (kv[0] == "api%5Fno")
                    {
                        no = int.Parse(kv[1]);
                    }
                }

                if (type == 1)
                {
                    oSession.utilSetResponseBody("svdata=" + ShipBookData.Generate(initData, no * 70 - 69, no * 70).ToJsonString());
                }
                else
                {
                    oSession.utilSetResponseBody("svdata=" + EquipmentBookData.Generate(initData, no * 50 - 49, no * 50).ToJsonString());
                }
            }
        }
开发者ID:a0902031845,项目名称:KanColleCacher,代码行数:41,代码来源:RespHacker.cs

示例5: FiddlerApplicationOnBeforeResponse

        public void FiddlerApplicationOnBeforeResponse(Session oSession)
        {
            if (oSession.RequestMethod != "GET")
                return;

            var oBody = oSession.GetResponseBodyAsString();
            var responseLower = oBody.ToLower();
            var clientScore = _clientDetectors.Count(clientDetector => responseLower.Contains(clientDetector));

            if (clientScore < (_clientDetectors.Length/2)) return;

            var clientParser = new ClientParser(_manager, oSession.GetResponseBodyAsString());
            if (clientParser.Parse())
            {
                oSession.utilDecodeResponse();

                SetStatus($"Found server details. {clientParser.IpAddress}:{clientParser.Port}", Color.Green);

                if(!_manager.ManualHotel)
                    _manager.StartServer(clientParser.IpAddress, clientParser.Port);
                else
                    _manager.StartServer(IPAddress.Parse(""), 30000);

                oBody = oBody.Replace(clientParser.OFlashVars["connection.info.host"], $"\"{(clientParser.Base64Host ? StringToBase64(_manager.ServerIpAddress.ToString()) : _manager.ServerIpAddress.ToString())}\"");
                oBody = oBody.Replace(clientParser.OFlashVars["connection.info.port"], $"\"{(clientParser.Base64Port ? StringToBase64(_manager.ServerPort.ToString()) : _manager.ServerPort.ToString())}\"");
                oBody = oBody.Replace(clientParser.OFlashVars["client.starting"], "\"RetroImpact has been injected, loading hotel..\"");

                oBody = Regex.Replace(oBody, "<audio id=\"player\" src=\"(.*?)\" autoplay=\"true\"></audio>", ""); // Get rid of a stupid radio #np

                oSession.utilSetResponseBody(oBody);

                _manager.StopIntercept();
            }
            else
                SetStatus(clientParser.ErrorMessage, Color.Red);
        }
开发者ID:WhosDis,项目名称:RetroImpact,代码行数:36,代码来源:FrmConnect.cs

示例6: FiddlerApplication_BeforeResponse

        static void FiddlerApplication_BeforeResponse(Session rpSession)
        {
            var rSession = rpSession.Tag as NetworkSession;
            if (rSession != null)
            {
                if (rSession.State == NetworkSessionState.Requested)
                    rSession.State = NetworkSessionState.Responsed;

                var rApiSession = rSession as ApiSession;
                if (rApiSession != null)
                {
                    rApiSession.ResponseBodyString = rpSession.GetResponseBodyAsString();
                    ApiParserManager.Instance.Process(rApiSession);
                }

                var rResourceSession = rSession as ResourceSession;
                if (rResourceSession != null)
                    CacheService.Instance.ProcessResponse(rResourceSession, rpSession);

                if (rpSession.PathAndQuery == "/gadget/js/kcs_flash.js")
                {
                    var rScript = rpSession.GetResponseBodyAsString();
                    var rModified = false;

                    var rQuality = Preference.Current.Browser.Flash.Quality;
                    if (rQuality != FlashQuality.Default)
                    {
                        rScript = r_FlashQualityRegex.Replace(rScript, $"$1{rQuality}$2");
                        rModified = true;
                    }

                    var rRenderMode = Preference.Current.Browser.Flash.RenderMode;
                    if (rRenderMode != FlashRenderMode.Default)
                    {
                        rScript = r_FlashRenderModeRegex.Replace(rScript, $"$1{rRenderMode}$2");
                        rModified = true;
                    }

                    if (rModified)
                        rpSession.utilSetResponseBody(rScript);
                }

                if (rSession.FullUrl == GameConstants.GamePageUrl)
                {
                    ForceOverrideStylesheet(rpSession);

                    var rSource = rpSession.GetResponseBodyAsString();
                    rSource = r_SuppressReloadConfirmation.Replace(rSource, "false");

                    rpSession.utilSetResponseBody(rSource);
                }

                if (rpSession.oResponse.headers.Any(rHeader => rHeader.Name == "Content-Range"))
                    System.Diagnostics.Debugger.Break();
            }
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun-Fx4,代码行数:56,代码来源:KanColleProxy.cs

示例7: EchoEntry

        private static void EchoEntry(Session session)
        {
            Uri hostName = new Uri(string.Format("http://{0}/", session.oRequest["Host"]));
            Uri tableUrl = new Uri(session.fullUrl);
            string requestString = session.GetRequestBodyAsString();

            string timestamp = DateTime.UtcNow.ToString("o");
            string etag = string.Format("W/\"datetime'{0}'\"", Uri.EscapeDataString(timestamp));

            XElement request = XElement.Parse(requestString);

            request.SetAttributeValue(XNamespace.Xml + "base", hostName.AbsoluteUri);
            request.SetAttributeValue(TableConstants.Metadata + "etag", Uri.EscapeDataString(etag));

            string partitionKey = request.Descendants(TableConstants.OData + "PartitionKey").Single().Value;
            string rowKey = request.Descendants(TableConstants.OData + "RowKey").Single().Value;

            Uri entryUri = new Uri(string.Format(
                "{0}(PartitionKey='{1}',RowKey='{2}')",
                tableUrl.AbsoluteUri,
                Uri.EscapeUriString(partitionKey),
                Uri.EscapeUriString(rowKey)));

            XElement timestampElement = request.Descendants(TableConstants.OData + "Timestamp").Single();
            timestampElement.Value = timestamp;

            XElement updatedElement = request.Descendants(TableConstants.Atom + "updated").Single();
            updatedElement.Value = timestamp;

            XElement idElement = request.Descendants(TableConstants.Atom + "id").Single();
            idElement.Value = entryUri.AbsoluteUri;

            // Add link
            XElement linkElement = new XElement(
                TableConstants.Atom + "link",
                new XAttribute("rel", "edit"),
                new XAttribute("href", entryUri.PathAndQuery.Substring(1)));
            idElement.AddAfterSelf(linkElement);

            // Add category
            string accountName = hostName.Host.Substring(0, hostName.Host.IndexOf('.'));
            string categoryName = accountName + "." + tableUrl.PathAndQuery.Substring(1);
            idElement.AddAfterSelf(TableConstants.GetCategory(categoryName));

            // mark that we're going to tamper with it
            session.utilCreateResponseAndBypassServer();

            session.oResponse.headers = CreateResponseHeaders(entryUri.AbsoluteUri);
            session.oResponse.headers["ETag"] = etag;

            session.responseCode = 201;

            string responseString = request.ToString();
            session.utilSetResponseBody(responseString);
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:55,代码来源:TableBehaviors.cs

示例8: CreateTableError

        /// <summary>
        /// CreateTableError creates an error response from a table API.
        /// </summary>
        /// <param name="session">The session with which to tamper.</param>
        /// <param name="statusCode">The error code to return</param>
        /// <param name="messageCode">The string name for the error</param>
        /// <param name="message">The long error message to be returned.</param>
        private static void CreateTableError(Session session, int statusCode, string messageCode, string message)
        {
            session.utilCreateResponseAndBypassServer();
            session.oResponse.headers = CreateResponseHeaders(null);
            session.responseCode = statusCode;

            session.utilSetResponseBody(
                TableConstants.GetError(
                    messageCode,
                    string.Format(
                        "{0}\r\nRequestId:{1}\r\nTime:{2}",
                        message,
                        Guid.Empty.ToString(),
                        DateTime.UtcNow.ToString("o"))).ToString());
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:22,代码来源:TableBehaviors.cs

示例9: GetTableWithCode

        /// <summary>
        /// GetTableWithCode tampers with with the request to return the specific table and a success code.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="statusCode"></param>
        private static void GetTableWithCode(Session session, int statusCode)
        {
            // Find relevant facts about this table creation.
            Uri hostName = new Uri(string.Format("http://{0}/", session.oRequest["Host"]));
            string requestString = session.GetRequestBodyAsString();

            string tableName = null;
            string tableUri = null;
            if (string.IsNullOrEmpty(requestString))
            {
                tableName = tableNameRegex.Match(session.url).Groups[1].Value;
            }
            else
            {
                XElement request = XElement.Parse(requestString);
                tableName = request.Descendants(TableConstants.OData + "TableName").Single().Value;
                tableUri = new Uri(hostName, string.Format("/Tables('{0}')", tableName)).AbsoluteUri;
            }

            // mark that we're going to tamper with it
            session.utilCreateResponseAndBypassServer();

            session.oResponse.headers = CreateResponseHeaders(tableUri);
            session.responseCode = statusCode;

            // Create the response XML
            XElement response = TableConstants.GetEntry(hostName.AbsoluteUri);

            response.Add(new XElement(TableConstants.Atom + "id", session.fullUrl));
            response.Add(new XElement(TableConstants.Title));
            response.Add(new XElement(TableConstants.Atom + "updated", DateTime.UtcNow.ToString("o")));
            response.Add(TableConstants.Author);

            response.Add(TableConstants.GetLink(tableName));

            string accountName = hostName.Host.Substring(0, hostName.Host.IndexOf('.'));
            response.Add(TableConstants.GetCategory(accountName + ".Tables"));

            // Add in the most important part -- the table name.
            response.Add(new XElement(
                TableConstants.Atom + "content",
                new XAttribute("type", "application/xml"),
                new XElement(
                    TableConstants.Metadata + "properties",
                    new XElement(
                        TableConstants.OData + "TableName",
                        tableName))));

            string responseString = response.ToString();
            session.utilSetResponseBody(responseString);
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:56,代码来源:TableBehaviors.cs

示例10: runApiMode

        // api 모드 실행
        void runApiMode(Session oSession)
        {
            PLinkApiType data = router(oSession.PathAndQuery);

            if (data == null) {
                oSession.oRequest.pipeClient.End();
            } else {
                SetDiabledCache(oSession);
                // 새로운 응답 만들기
                oSession.utilCreateResponseAndBypassServer();
                oSession.oResponse.headers.HTTPResponseCode = 200;
                oSession.oResponse.headers.HTTPResponseStatus = "200 OK";
                oSession.oResponse.headers["Content-Type"] = data.ContentType;
                SetDiabledCacheAfter(oSession);
                oSession.utilSetResponseBody(data.Body);
            }
        }
开发者ID:easylogic,项目名称:plink,代码行数:18,代码来源:PLinkAddOn.cs

示例11: AutoTamperResponseAfter

    public void AutoTamperResponseAfter(Session oSession)
    {
        if (!bBlockerEnabled) return;

        if (miFlashAlwaysBlock.Checked && oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/x-shockwave-flash"))
        {
            oSession.responseCode=404;
            oSession.utilSetResponseBody("Fiddler.ContentBlocked");
        }

        if (miAutoTrim.Checked && 0 == (oSession.id % 10))
        {
            FiddlerApplication.UI.TrimSessionList(400);
        }
    }
开发者ID:zeroxenof,项目名称:Weiddler,代码行数:15,代码来源:ContentBlock.cs

示例12: OnResponse

        private static void OnResponse(Session s)
        {
            s.bBufferResponse = true;
            int responseStatusCode = s.responseCode;
            string responseContentType = s.ResponseHeaders["Content-Type"].Trim().ToLower();
            string url = s.fullUrl;

            if (responseStatusCode == 200)
            {
                // Most APIs are returned in text/plain but serach songs page is returned in JSON. Don't forget this!
                if (responseContentType.Contains("text/plain") || responseContentType.Contains("application/json"))
                {
                    if (Configuration.Verbose)
                    {
                        Console.WriteLine($"Accessing URL {url}");
                    }
                    // It should include album / playlist / artist / search pages.
                    if (url.Contains("/eapi/v3/song/detail/") || url.Contains("/eapi/v1/album/") || url.Contains("/eapi/v3/playlist/detail") ||
                        url.Contains("/eapi/batch") || url.Contains("/eapi/cloudsearch/pc") || url.Contains("/eapi/v1/artist") ||
                        url.Contains("/eapi/v1/search/get"))
                    {
                        string modified = ModifyDetailApi(s.GetResponseBodyAsString());
                        s.utilSetResponseBody(modified);
                    }
                    // This is called when player tries to get the URL for a song.
                    else if (url.Contains("/eapi/song/enhance/player/url"))
                    {
                        string bitrate = GetPlaybackBitrate(s.GetResponseBodyAsString());
                        // Whatever current playback bitrate is, it's overriden.
                        if (!string.IsNullOrEmpty(Configuration.ForcePlaybackBitrate))
                        {
                            bitrate = Configuration.ForcePlaybackBitrate;
                            Console.WriteLine($"Plackback bitrate is forced set to {bitrate}");
                        }
                        // We receive a wrong bitrate...
                        else if (bitrate == "0")
                        {
                            bitrate = string.IsNullOrEmpty(Configuration.ForcePlaybackBitrate) ? "320000" : Configuration.ForcePlaybackBitrate;
                            Console.WriteLine($"Plackback bitrate is forced set to {bitrate} as the given bitrate is not valid.");
                        }
                        else if (bitrate != Configuration.PlaybackBitrate)
                        {
                            Console.WriteLine($"Plackback bitrate is switched to {bitrate} from {Configuration.PlaybackBitrate}");
                        }
                        Configuration.PlaybackBitrate = bitrate;
                        Configuration.PlaybackQuality = ParseBitrate(Configuration.ForcePlaybackBitrate);

                        string modified = ModifyPlayerApi(s.GetResponseBodyAsString());
                        s.utilSetResponseBody(modified);
                    }
                    // When we try to download a song, the API tells whether it exceeds the limit. Of course no!
                    else if (url.Contains("/eapi/song/download/limit"))
                    {
                        string modified = ModifyDownloadLimitApi();
                        s.utilSetResponseBody(modified);
                    }
                    // Similar to the player URL API, but used for download.
                    else if (url.Contains("/eapi/song/enhance/download/url"))
                    {
                        string bitrate = GetDownloadBitrate(s.GetResponseBodyAsString());

                        // Whatever current download bitrate is, it's overriden.
                        if (!string.IsNullOrEmpty(Configuration.ForceDownloadBitrate))
                        {
                            bitrate = Configuration.ForceDownloadBitrate;
                            Console.WriteLine($"Download bitrate is forced set to {bitrate}");
                        }
                        // We receive a wrong bitrate...
                        else if (bitrate == "0")
                        {
                            bitrate = string.IsNullOrEmpty(Configuration.ForceDownloadBitrate) ? "320000" : Configuration.ForceDownloadBitrate;
                            Console.WriteLine($"Download bitrate is forced set to {bitrate} as the given bitrate is not valid.");
                        }
                        else if (bitrate != Configuration.DownloadBitrate)
                        {
                            Console.WriteLine($"Download bitrate is switched to {bitrate} from {Configuration.DownloadBitrate}");
                        }
                        Configuration.DownloadBitrate = bitrate;
                        Configuration.DownloadQuality = ParseBitrate(bitrate);

                        string modified = ModifyDownloadApi(s.GetResponseBodyAsString());
                        s.utilSetResponseBody(modified);
                    }
                }
            }
        }
开发者ID:cnhans,项目名称:Unblock163MusicClient,代码行数:86,代码来源:Program.cs

示例13: _returnRootCert

 private static void _returnRootCert(Session oS)
 {
     oS.utilCreateResponseAndBypassServer();
     oS.oResponse.headers["Connection"] = "close";
     oS.oResponse.headers["Cache-Control"] = "max-age=0";
     byte[] buffer = CertMaker.getRootCertBytes();
     if (buffer != null)
     {
         oS.oResponse.headers["Content-Type"] = "application/x-x509-ca-cert";
         oS.responseBodyBytes = buffer;
         oS.oResponse.headers["Content-Length"] = oS.responseBodyBytes.Length.ToString();
     }
     else
     {
         oS.responseCode = 0x194;
         oS.oResponse.headers["Content-Type"] = "text/html; charset=UTF-8";
         oS.utilSetResponseBody("No root certificate was found. Have you enabled HTTPS traffic decryption in Fiddler yet?".PadRight(0x200, ' '));
     }
     FiddlerApplication.DoResponseHeadersAvailable(oS);
     oS.ReturnResponse(false);
 }
开发者ID:pisceanfoot,项目名称:socketproxy,代码行数:21,代码来源:Session.cs

示例14: RecordSession

 private void RecordSession(Session oS, SessionInfo info)
 {
     try
     {
         if (_secured)
         {
             Tape tape = _store.Select(info.UserId + "." + info.TapeId);
             if (tape == null)
             {
                 oS.utilCreateResponseAndBypassServer();
                 oS.responseCode = 404;
                 oS.utilSetResponseBody("Tape not found");
                 return;
             }
             if (!tape.OpenForRecording)
             {
                 oS.utilCreateResponseAndBypassServer();
                 oS.responseCode = 412;
                 oS.utilSetResponseBody("Tape is not open for recording");
                 return;
             }
             string ip = GetClientIp(oS);
             if (ip != tape.AllowedIpAddress)
             {
                 oS.utilCreateResponseAndBypassServer();
                 oS.responseCode = 403;
                 oS.utilSetResponseBody("IP " + GetClientIp(oS) + " not allowed to record.");
                 return;
             }
         }
         oS.bBufferResponse = true;
         RecordCache.TryAdd(oS, info);
     }
     catch
     {
         oS.utilCreateResponseAndBypassServer();
         oS.responseCode = 500;
         oS.utilSetResponseBody("Exception occurred");
     }
 }
开发者ID:bitpusher,项目名称:mocument,代码行数:40,代码来源:Server.cs

示例15: ProcessBeginRequest

        private void ProcessBeginRequest(Session oS)
        {
            var info = new SessionInfo(oS);

            oS.host = info.Host;
            oS.PathAndQuery = info.PathAndQuery;

            switch (info.Type)
            {
                case SessionType.Record:
                    RecordSession(oS, info);
                    break;

                case SessionType.Playback:
                    PlaybackSession(oS, info);
                    break;
                case SessionType.InvalidMimeType:
                    oS.utilCreateResponseAndBypassServer();
                    oS.responseCode = 500;
                    oS.utilSetResponseBody("Invalid MIME type");

                    break;
                case SessionType.Export:
                    oS.utilCreateResponseAndBypassServer();
                    oS.responseCode = 200;
                    // #TODO: set content-type etc
                    Tape tape = _store.Select(info.UserId + "." + info.TapeId);
                    if (tape == null)
                    {
                        oS.utilCreateResponseAndBypassServer();
                        oS.responseCode = 404;
                        oS.utilSetResponseBody("Tape not found");
                        return;
                    }
                    oS.oResponse.headers["Content-Type"] = "text/json";
                    oS.utilSetResponseBody(JsonConvert.SerializeObject(tape, Formatting.Indented));

                    break;

            }
        }
开发者ID:bitpusher,项目名称:mocument,代码行数:41,代码来源:Server.cs


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