예제 #1
0
        public bool ExportSessions(string sFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> evtProgressNotifications)
        {
            if (sFormat != "HTTPArchive v1.1" && sFormat != "HTTPArchive v1.2")
            {
                return(false);
            }
            bool   result = false;
            string text   = null;
            int    iMaxBinaryBodyLength = FiddlerApplication.get_Prefs().GetInt32Pref("fiddler.importexport.HTTPArchiveJSON.MaxBinaryBodyLength", 32768);
            int    iMaxTextBodyLength   = FiddlerApplication.get_Prefs().GetInt32Pref("fiddler.importexport.HTTPArchiveJSON.MaxTextBodyLength", 22);

            if (dictOptions != null)
            {
                if (dictOptions.ContainsKey("Filename"))
                {
                    text = (dictOptions["Filename"] as string);
                }
                if (dictOptions.ContainsKey("MaxTextBodyLength"))
                {
                    iMaxTextBodyLength = (int)dictOptions["MaxTextBodyLength"];
                }
                if (dictOptions.ContainsKey("MaxBinaryBodyLength"))
                {
                    iMaxBinaryBodyLength = (int)dictOptions["MaxBinaryBodyLength"];
                }
            }
            if (string.IsNullOrEmpty(text))
            {
                text = Utilities.ObtainSaveFilename("Export As " + sFormat, "HTTPArchive JSON (*.har)|*.har");
            }
            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    StreamWriter streamWriter = new StreamWriter(text, false, Encoding.UTF8);
                    HTTPArchiveJSONExport.WriteStream(streamWriter, oSessions, sFormat == "HTTPArchive v1.2", evtProgressNotifications, iMaxTextBodyLength, iMaxBinaryBodyLength);
                    streamWriter.Close();
                    bool result2 = true;
                    return(result2);
                }
                catch (Exception ex)
                {
                    FiddlerApplication.ReportException(ex, "Failed to save HTTPArchive");
                    bool result2 = false;
                    return(result2);
                }
                return(result);
            }
            return(result);
        }
예제 #2
0
        public bool ExportSessions(string sFormat, Session[] oSessions, Dictionary <string, object> dictOptions, EventHandler <ProgressCallbackEventArgs> evtProgressNotifications)
        {
            if ((sFormat != "HTTPArchive v1.1") && (sFormat != "HTTPArchive v1.2"))
            {
                return(false);
            }
            string str = null;
            int    iMaxBinaryBodyLength = FiddlerApplication.Prefs.GetInt32Pref("fiddler.importexport.HTTPArchiveJSON.MaxBinaryBodyLength", 0x8000);
            int    iMaxTextBodyLength   = FiddlerApplication.Prefs.GetInt32Pref("fiddler.importexport.HTTPArchiveJSON.MaxTextBodyLength", 0x16);

            if (dictOptions != null)
            {
                if (dictOptions.ContainsKey("Filename"))
                {
                    str = dictOptions["Filename"] as string;
                }
                if (dictOptions.ContainsKey("MaxTextBodyLength"))
                {
                    iMaxTextBodyLength = (int)dictOptions["MaxTextBodyLength"];
                }
                if (dictOptions.ContainsKey("MaxBinaryBodyLength"))
                {
                    iMaxBinaryBodyLength = (int)dictOptions["MaxBinaryBodyLength"];
                }
            }
            if (string.IsNullOrEmpty(str))
            {
                str = Utilities.ObtainSaveFilename("Export As " + sFormat, "HTTPArchive JSON (*.har)|*.har");
            }
            if (!string.IsNullOrEmpty(str))
            {
                try
                {
                    StreamWriter swOutput = new StreamWriter(str, false, Encoding.UTF8);
                    HTTPArchiveJSONExport.WriteStream(swOutput, oSessions, sFormat == "HTTPArchive v1.2", evtProgressNotifications, iMaxTextBodyLength, iMaxBinaryBodyLength);
                    swOutput.Close();
                    return(true);
                }
                catch (Exception exception)
                {
                    FiddlerApplication.ReportException(exception, "Failed to save HTTPArchive");
                    return(false);
                }
            }
            return(false);
        }