本文整理汇总了C#中Fiddler.Session.GetResponseBodyEncoding方法的典型用法代码示例。如果您正苦于以下问题:C# Session.GetResponseBodyEncoding方法的具体用法?C# Session.GetResponseBodyEncoding怎么用?C# Session.GetResponseBodyEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fiddler.Session
的用法示例。
在下文中一共展示了Session.GetResponseBodyEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processRuleForSession
private void processRuleForSession(Session oSession, String ruleStr)
{
oSession.utilDecodeResponse();
// check 304
if (oSession.responseCode.ToString() == "304")
{
if (MessageBox.Show("This request session's ResponseCode is 304, means no data responded!\nContinue to Edit?", "Fedit Warning:",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return;
}
// check encode type
FiddlerApplication.Log.LogString(oSession.GetResponseBodyEncoding().ToString());
String tmp_filetype;
if (fileType.ContainsKey(oSession.oResponse.MIMEType.ToString()))
{
tmp_filetype = (String)fileType[oSession.oResponse.MIMEType.ToString()];
}
else
{
Stack<string> ext = new Stack<string>(oSession.fullUrl.Split(new string[] { "." }, StringSplitOptions.None));
tmp_filetype = "." + Regex.Replace(ext.Pop(), @"([a-zA-Z\d]+?)[^a-zA-Z\d].+", "$1");
}
String escaped_url = System.Uri.EscapeDataString(oSession.fullUrl);
String tmp_filename = escaped_url.Substring(0, escaped_url.Length < 150 ? escaped_url.Length : 150) + tmp_filetype;
String fedit_file = fedit_path + "\\" + tmp_filename;
FiddlerApplication.Log.LogString("Saving url \"" + oSession.fullUrl + "\" to temp file \"" + fedit_file + "\"");
if (oSession.oResponse.headers.ToString().ToLower().IndexOf("content-encoding:") >= 0)
{
// if encoded, decode it
File.WriteAllBytes(fedit_file, oSession.responseBodyBytes);
}
else
{
// else load bytes
File.WriteAllBytes(fedit_file, oSession.responseBodyBytes);
}
FiddlerApplication.Log.LogString(tmp_filename);
// add AotuResponse rule
if (tmp_rules.ContainsKey(oSession.fullUrl))
{
FiddlerApplication.oAutoResponder.RemoveRule((Fiddler.ResponderRule)tmp_rules[oSession.fullUrl]);
}
else
{
tmp_rules.Add(oSession.fullUrl, "");
}
tmp_rules[oSession.fullUrl] = (Fiddler.ResponderRule)FiddlerApplication.oAutoResponder.AddRule((ruleStr==""||ruleStr==null)?"EXACT:" + oSession.fullUrl:ruleStr, fedit_file, true);
if(!FiddlerApplication.oAutoResponder.IsEnabled)
MessageBox.Show("Notice! AutoResponder is not enabled! Please enable this.");
FiddlerApplication.Log.LogString("Open file \"" + fedit_file + "\"");
// edit file with default editor
if (editor_setting.ContainsKey(tmp_filetype))
{
System.Diagnostics.Process.Start(editor_setting[tmp_filetype].ToString(), "\"" + fedit_file + "\"");
}
else
{
System.Diagnostics.Process.Start(editor_setting["default"].ToString(), "\"" + fedit_file + "\"");
}
FiddlerApplication.Log.LogString(fedit_file);
}