本文整理汇总了C#中Fiddler.Session.LoadResponseFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# Session.LoadResponseFromFile方法的具体用法?C# Session.LoadResponseFromFile怎么用?C# Session.LoadResponseFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fiddler.Session
的用法示例。
在下文中一共展示了Session.LoadResponseFromFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFromCache
public bool LoadFromCache(Session oSession)
{
bool success = false;
string key = oSession.fullUrl;
if (!cache.ContainsKey(key))
{
if (key.Contains('?')) {
key = key.Substring(0, key.IndexOf('?'));
}
}
if (cache.ContainsKey(key))
{
CacheItem item = cache[key];
if (item.CheckState == System.Windows.Forms.CheckState.Checked
&& File.Exists(item.Local))
{
oSession.utilCreateResponseAndBypassServer();
item.SetSessionResponse(oSession);
success = oSession.LoadResponseFromFile(item.Local);
}
}
return success;
}
示例2: ReadSessionData
/// <summary>
/// 从本地读取 api_start2 通信数据
/// </summary>
static object ReadSessionData(string path)
{
//var path = Settings.Current.CacheFolder + "\\api_start2.dat";
//var bytes = Encoding.UTF8.GetBytes(File.ReadAllText(path));
//var serializer = new DataContractJsonSerializer(typeof(svdata<kcsapi_start2>));
//using (var stream = new MemoryStream(bytes))
//{
// return serializer.ReadObject(stream) as svdata<kcsapi_start2>;
//}
Session session = new Session(new byte[] { 0 }, new byte[] { 0 });
if (!session.LoadRequestBodyFromFile(path))
{
throw new ApplicationException("LoadRequestBodyFromFile Failed!! " + path);
}
if (!session.LoadResponseFromFile(path))
{
throw new ApplicationException("LoadResponseFromFile Failed!! " + path);
}
return session;
}
示例3: IgnoreResponse
/// <summary>
/// IgnoreResponse ignores the incoming response.
/// </summary>
/// <param name="relevantSession">The session whose response should be failed.</param>
private static void IgnoreResponse(Session relevantSession)
{
relevantSession.LoadResponseFromFile(StockResponses.NoContent204);
}
示例4: AutoTamperRequestBefore
public void AutoTamperRequestBefore(Session oSession)
{
if (!IsEnabled)
{
return;
}
string fullString = oSession.fullUrl.ToLower();
if (fullString.EndsWith("imposter.js") && EnableAutoReload)
{
oSession.utilCreateResponseAndBypassServer();
var js = Path.GetFullPath("Scripts\\imposter.js");
oSession.LoadResponseFromFile(js);
oSession.ResponseHeaders.Add("x-imposter", js);
}
if (fullString.ToLower().Contains("/imposter-poll-for-changes?profileid=") && EnableAutoReload)
{
var profileIdIndex = fullString.ToLower().IndexOf("/imposter-poll-for-changes?profileid=");
var profileIdFragment = fullString.Substring(profileIdIndex + "/imposter-poll-for-changes?profileid=".Length);
Guid profileId;
var success = Guid.TryParse(profileIdFragment, out profileId);
oSession.utilCreateResponseAndBypassServer();
oSession.ResponseHeaders.Add("x-imposter", "AUTO RELOAD");
if (success && _enabledProfiles.Any(p => p.ProfileId == profileId && p.HasChanges))
{
oSession.utilSetResponseBody("true");
_enabledProfiles.ForEach(p => p.HasChanges = false);
}
else
{
oSession.utilSetResponseBody("false");
}
}
foreach (var profile in _enabledProfiles)
{
var path = profile.GetFileMatch(fullString);
if (path == null)
{
continue;
}
oSession.utilCreateResponseAndBypassServer();
oSession.LoadResponseFromFile(path);
oSession.ResponseHeaders.Add("x-imposter", path);
if (oSession.ViewItem != null)
{
oSession.ViewItem.BackColor = Color.SkyBlue;
}
// Only swap for the first match
break;
}
}