private AssignFromString ( string sHeaders ) : bool | ||
sHeaders | string | |
return | bool |
public bool LoadRules(string sFilename, bool bIsDefaultRuleFile) { if (bIsDefaultRuleFile) { this.ClearRules(); } try { if (!File.Exists(sFilename) || (new FileInfo(sFilename).Length < 0x8fL)) { return(false); } FileStream input = new FileStream(sFilename, FileMode.Open, FileAccess.Read, FileShare.Read); XmlTextReader reader = new XmlTextReader(input); while (reader.Read()) { string str6; if ((reader.NodeType == XmlNodeType.Element) && ((str6 = reader.Name) != null)) { if (!(str6 == "State")) { if (str6 == "ResponseRule") { goto Label_00B8; } } else if (bIsDefaultRuleFile) { this.IsEnabled = XmlConvert.ToBoolean(reader.GetAttribute("Enabled")); this.PermitFallthrough = XmlConvert.ToBoolean(reader.GetAttribute("Fallthrough")); } } continue; Label_00B8: try { string attribute = reader.GetAttribute("Match"); string sAction = reader.GetAttribute("Action"); int iLatencyMS = 0; string s = reader.GetAttribute("Latency"); if (s != null) { iLatencyMS = XmlConvert.ToInt32(s); } bool bIsEnabled = "false" != reader.GetAttribute("Enabled"); string str4 = reader.GetAttribute("Headers"); if (string.IsNullOrEmpty(str4)) { this.AddRule(attribute, sAction, bIsEnabled); } else { byte[] buffer; HTTPResponseHeaders oRH = new HTTPResponseHeaders(); str4 = Encoding.UTF8.GetString(Convert.FromBase64String(str4)); oRH.AssignFromString(str4); string str5 = reader.GetAttribute("DeflatedBody"); if (!string.IsNullOrEmpty(str5)) { buffer = Utilities.DeflaterExpand(Convert.FromBase64String(str5)); } else { str5 = reader.GetAttribute("Body"); if (!string.IsNullOrEmpty(str5)) { buffer = Convert.FromBase64String(str5); } else { buffer = new byte[0]; } } this.AddRule(attribute, oRH, buffer, sAction, iLatencyMS, bIsEnabled); } continue; } catch { continue; } } reader.Close(); if (bIsDefaultRuleFile && (this._alRules.Count < 1)) { this.IsEnabled = false; } if (bIsDefaultRuleFile) { this._bRuleListIsDirty = false; } return(true); } catch (Exception exception) { FiddlerApplication.ReportException(exception, "Failed to load AutoResponder settings from " + sFilename); if (bIsDefaultRuleFile) { this.IsEnabled = false; } return(false); } }