Ejemplo n.º 1
0
        internal WPRImporter(StreamReader oSR, List <Session> listSessions, EventHandler <ProgressCallbackEventArgs> evtProgressNotifications)
        {
            _listSessions             = listSessions;
            _evtProgressNotifications = evtProgressNotifications;
            Stopwatch oSW    = Stopwatch.StartNew();
            Hashtable htFile = JSON.JsonDecode(oSR.ReadToEnd(), out _) as Hashtable;

            if (null == htFile)
            {
                NotifyProgress(1.00f, "Aborting; file is not a properly-formatted WPR Capture.");
                FiddlerApplication.DoNotifyUser("This file is not a properly-formatted WPR Capture.", "Import aborted");
                return;
            }

            NotifyProgress(0.25f, "Finished parsing JSON file; took " + oSW.ElapsedMilliseconds + "ms.");
            if (!ExtractSessionsFromJSON(htFile))
            {
                FiddlerApplication.DoNotifyUser("This JSON file does not seem to contain WPR Capture data.", "Unexpected Data");
                Session sessFile = Session.BuildFromData(false,
                                                         new HTTPRequestHeaders(
                                                             String.Format("/file.json"),
                                                             new[] { "Host: failed-import", "Date: " + DateTime.UtcNow.ToString() }),
                                                         Utilities.emptyByteArray,
                                                         new HTTPResponseHeaders(200, "File Data", new[] { "Content-Type: application/json; charset=utf-8" }),
                                                         Encoding.UTF8.GetBytes(JSON.JsonEncode(htFile)),
                                                         SessionFlags.ImportedFromOtherTool | SessionFlags.RequestGeneratedByFiddler | SessionFlags.ResponseGeneratedByFiddler | SessionFlags.ServedFromCache);
                listSessions.Insert(0, sessFile);
            }
        }
Ejemplo n.º 2
0
        public void OnLoad()
        {
            //新建一个Fiddler插件的page
            TabPage page = new TabPage("Heelo World");

            //将page加入Fiddler的tab选项卡中
            FiddlerApplication.UI.tabsViews.TabPages.Add(page);
            //输出Hello World
            FiddlerApplication.DoNotifyUser("Hello", "Hello World");
        }
Ejemplo n.º 3
0
        public static bool WriteSessionArchive(string sFilename, Session[] arrSessions, string sPassword, bool bVerboseDialogs)
        {
            if (arrSessions == null || arrSessions.Length < 1)
            {
                if (bVerboseDialogs)
                {
                    FiddlerApplication.DoNotifyUser("No sessions were provided to save to the archive.", "WriteSessionArchive - No Input");
                }
                return(false);
            }
            if (FiddlerApplication.oSAZProvider == null)
            {
                throw new NotSupportedException("This application was compiled without .SAZ support.");
            }
            //FiddlerApplication.DoBeforeSaveSAZ(sFilename, arrSessions);
            bool result;

            try
            {
                if (File.Exists(sFilename))
                {
                    File.Delete(sFilename);
                }
                ISAZWriter iSAZWriter = FiddlerApplication.oSAZProvider.CreateSAZ(sFilename);
                if (!string.IsNullOrEmpty(sPassword))
                {
                    iSAZWriter.SetPassword(sPassword);
                }
                iSAZWriter.Comment = "Fiddler Session Archive. See http://fiddler2.com";
                int    num = 1;
                string sFileNumberFormat = "D" + arrSessions.Length.ToString().Length;
                for (int i = 0; i < arrSessions.Length; i++)
                {
                    Session oSession = arrSessions[i];
                    WriteSessionToSAZ(oSession, iSAZWriter, num, sFileNumberFormat, null, bVerboseDialogs);
                    num++;
                }
                iSAZWriter.CompleteArchive();
                result = true;
            }
            catch (Exception ex)
            {
                if (bVerboseDialogs)
                {
                    FiddlerApplication.DoNotifyUser("Failed to save Session Archive.\n\n" + ex.Message, "Save Failed");
                }
                result = false;
            }
            return(result);
        }