本文整理汇总了C#中Fiddler.Session类的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于Fiddler命名空间,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRequestFromSession
public static HttpRequestMessage CreateRequestFromSession(Session session)
{
var request = new HttpRequestMessage
{
RequestUri = new Uri(session.fullUrl, UriKind.RelativeOrAbsolute),
Method = new HttpMethod(session.RequestMethod)
};
var failedHeaders = new List<HTTPHeaderItem>();
foreach (var header in session.oRequest.headers)
{
if (!request.Headers.TryAddWithoutValidation(header.Name, header.Value))
{
failedHeaders.Add(header);
}
}
if (session.RequestBody.Length > 0)
{
request.Content = new ByteArrayContent(session.RequestBody);
foreach (var header in failedHeaders)
{
request.Content.Headers.TryAddWithoutValidation(header.Name, header.Value);
}
}
return request;
}
示例2: FiddlerApplication_BeforeRequest
static void FiddlerApplication_BeforeRequest(Session rpSession)
{
if (Preference.Current.Network.UpstreamProxy.Enabled)
rpSession["x-OverrideGateway"] = Preference.Current.Network.UpstreamProxy.Address;
var rRequest = rpSession.oRequest;
var rFullUrl = rpSession.fullUrl;
var rPath = rpSession.PathAndQuery;
NetworkSession rSession;
if (rPath.StartsWith("/kcsapi/"))
rSession = new ApiSession(rFullUrl);
else if (rPath.StartsWith("/kcs/") || rPath.StartsWith("/gadget/"))
rSession = new ResourceSession(rFullUrl, rPath);
else
rSession = new NetworkSession(rFullUrl);
rSession.RequestBodyString = Uri.UnescapeDataString(rpSession.GetRequestBodyAsString());
rpSession.Tag = rSession;
SessionSubject.OnNext(rSession);
if (rFullUrl == GameConstants.GamePageUrl || rPath == "/gadget/js/kcs_flash.js")
rpSession.bBufferResponse = true;
var rResourceSession = rSession as ResourceSession;
if (rResourceSession != null)
CacheService.Instance.ProcessRequest(rResourceSession, rpSession);
}
示例3: AutoTamperRequestBefore
public void AutoTamperRequestBefore(Session oSession)
{
if (cacheController != null)
{
cacheController.Filter(oSession);
}
}
示例4: FiddlerApplication_BeforeRequest
void FiddlerApplication_BeforeRequest(Session oSession)
{
if (oSession.LocalProcess.ToLower().Contains("skypebot2"))
{
oSession.Ignore();
}
}
示例5: _BeforeRequest
//This event fires when a client request is received by Fiddler
static void _BeforeRequest(Session oSession)
{
if (!Settings.Current.CacheEnabled) return;
if (!_Filter(oSession)) return;
string filepath;
var direction = cache.GotNewRequest(oSession.fullUrl, out filepath);
if (direction == Direction.Return_LocalFile)
{
//返回本地文件
oSession.utilCreateResponseAndBypassServer();
oSession.ResponseBody = File.ReadAllBytes(filepath);
_CreateResponseHeader(oSession, filepath);
//Debug.WriteLine("CACHR> 【返回本地】" + filepath);
}
else if (direction == Direction.Verify_LocalFile)
{
//请求服务器验证文件
//oSession.oRequest.headers["If-Modified-Since"] = result;
oSession.oRequest.headers["If-Modified-Since"] = _GetModifiedTime(filepath);
oSession.bBufferResponse = true;
//Debug.WriteLine("CACHR> 【验证文件】" + oSession.PathAndQuery);
}
else
{
//下载文件
}
}
示例6: Export
public static Entry Export(Session session, bool requestOnly = false)
{
var entry = new Entry();
entry.startedDateTime = session.Timers.ClientBeginRequest.ToString("o");
entry.request = GetRequest(session);
if (!requestOnly)
{
entry.response = GetResponse(session);
}
entry.timings = GetTimings(session.Timers);
entry.comment = session["ui-comments"];
entry.time = GetTotalTime(entry.timings);
if (
!string.IsNullOrEmpty(session["ui-comments"])
// <-- not sure if this is correct, maybe a typo or missing assignation in BasicFormats?
&& !session.isFlagSet(SessionFlags.SentToGateway))
{
entry.serverIPAddress = session.m_hostIP;
}
entry.connection = session.clientPort.ToString(CultureInfo.InvariantCulture);
return entry;
}
示例7: FiddlerApplication_BeforeResponse
void FiddlerApplication_BeforeResponse(FiddlerSession rpSession)
{
var rSession = rpSession.Tag as Session;
if (rSession != null)
{
if (rSession.Status == SessionStatus.Request)
rSession.Status = SessionStatus.Responsed;
var rApiSession = rSession as ApiSession;
if (rApiSession != null)
{
rApiSession.ResponseString = rpSession.GetResponseBodyAsString();
ApiParsers.Post(rApiSession);
}
var rResourceSession = rSession as ResourceSession;
if (rResourceSession != null && ResourceCache.IsEnabled && rpSession.responseCode == 200 && !File.Exists(rResourceSession.CachePath) && rpSession.oResponse["Last-Modified"] != null)
{
rResourceSession.Data = rpSession.ResponseBody;
rResourceSession.LastModifiedTime = Convert.ToDateTime(rpSession.oResponse["Last-Modified"]);
ResourceCache.SaveFile(rResourceSession);
}
if (rSession.Url.Contains("kcs/sound/titlecall/") || rSession.Url.Contains("api_start2"))
KanColleGame.Current.RaiseGameLaunchedEvent();
}
Debug.WriteLine("Response - " + rpSession.fullUrl);
}
示例8: ExportSessions
public bool ExportSessions(string sFormat, Session[] oSessions, Dictionary<string, object> dictOptions,
EventHandler<ProgressCallbackEventArgs> evtProgressNotifications)
{
bool bResult = true;
string sFilename = null;
// [3] Ask the Fiddler GUI to obtain the filename to export to
sFilename = Fiddler.Utilities.ObtainSaveFilename("Export As " + sFormat, "JMeter Files (*.jmx)|*.jmx");
if (String.IsNullOrEmpty(sFilename)) return false;
if (!Path.HasExtension(sFilename)) sFilename = sFilename + ".jmx";
try
{
Encoding encUTF8NoBOM = new UTF8Encoding(false);
JMeterTestPlan jMeterTestPlan = new JMeterTestPlan(oSessions, sFilename);
System.IO.StreamWriter sw = new StreamWriter(sFilename, false, encUTF8NoBOM);
sw.Write(jMeterTestPlan.getJmx());
sw.Close();
}
catch (Exception eX)
{
Fiddler.FiddlerApplication.Log.LogString(eX.Message);
Fiddler.FiddlerApplication.Log.LogString(eX.StackTrace);
bResult = false;
}
return bResult;
}
示例9: AutoTamperRequestBefore
public void AutoTamperRequestBefore(Session oSession)
{
if (model.Enabled)
{
// if (m_SimulateModem) {
// // Delay sends by 300ms per KB uploaded.
// oSession["request-trickle-delay"] = "30";
// // Delay receives by 150ms per KB downloaded.
// oSession["response-trickle-delay"] = "150";
//}
int requestDelay = SpeedConvert.covert(model.RequestDelaySpeed);
int reponseDelay = SpeedConvert.covert(model.ReponseDelaySpeed);
oSession["request-trickle-delay"] = Convert.ToString(requestDelay);
oSession["response-trickle-delay"] = Convert.ToString(reponseDelay);
}
else
{
oSession["request-trickle-delay"] = null;
oSession["response-trickle-delay"] = null;
}
// oSession.oRequest["User-Agent"] = sUserAgent;
}
示例10: InspectSession
private void InspectSession(Session[] sessions)
{
var session = sessions[0];
var requestBody = session.GetRequestBodyAsString();
var responseBody = session.GetResponseBodyAsString();
var requestHeaders = GetHeaders(session.RequestHeaders);
var timers = session.Timers;
var sessionTime = timers.ClientDoneResponse - timers.ClientBeginRequest;
try
{
var inspector = new Inspector(requestBody, responseBody, requestHeaders, sessionTime);
var actions = inspector.GetActionsData();
var requestData = inspector.GetRequestData();
var responseData = inspector.GetResponseData();
RequestViewModel.Actions = new ObservableCollection<ActionBase>(actions);
RequestViewModel.ErrorInfo = responseData.ErrorInfo;
RequestInfoViewModel.SetSessionData(requestData, responseData, sessionTime, session.RequestBody.Length, session.ResponseBody.Length);
}
catch
{
RequestViewModel.Actions = new ObservableCollection<ActionBase>();
RequestInfoViewModel.ClearSessionData();
}
}
示例11: AutoTamperRequestBefore
public void AutoTamperRequestBefore(Session oSession)
{
// Check that our plugin has been enabled
if (authTab.IsEnabled == false)
{
return;
}
// Clone our existing request
HTTPRequestHeaders oNewHeaders = oSession.oRequest.headers.Clone() as HTTPRequestHeaders;
byte[] requestBody = oSession.requestBodyBytes;
// Look for any configuration data values to remove
FiddlerApplication.Log.LogString(String.Format("COOKIE: {0}", oNewHeaders["Cookie"]));
// Check that we haven't already sent a modified response
if (!oSession.oFlags.ContainsKey("repeat-request"))
{
if (StripSessionFromRequest(oNewHeaders, ref requestBody))
{
// Add our tracking flag
StringDictionary flags = new StringDictionary();
flags.Add("repeat-request", "true");
FiddlerApplication.oProxy.InjectCustomRequest(oNewHeaders, requestBody, flags);
}
}
}
示例12: FiddlerApplication_BeforeResponse
static void FiddlerApplication_BeforeResponse(Session oSession)
{
string url = oSession.url;
DateTime start = oSession.Timers.ClientBeginRequest;
DateTime end = oSession.Timers.ClientDoneResponse;
TimeSpan t = end - start;
if (oSession.host != filter)
return;
if(oSession.Timers.DNSTime > 0)
Console.WriteLine("DNS TIME: {0}", oSession.Timers.DNSTime);
if (!sdata.Keys.Contains(url))
sdata[url] = new List<RequestAggregate>();
RequestAggregate rq = new RequestAggregate()
{
data_size = oSession.GetResponseBodyAsString().Length,
host = oSession.host,
time = t.TotalMilliseconds
};
Monitor.Enter(sdata[url]);
sdata[url].Add(rq);
Monitor.Exit(sdata[url]);
ConsoleColor c = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("{0} ==> {1}", oSession.url, end-start);
Console.ForegroundColor = defaultColor;
}
示例13: FiddlerApplication_BeforeRequest
static void FiddlerApplication_BeforeRequest(Session oSession)
{
ConsoleColor c = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("{0}", oSession.url);
Console.ForegroundColor = defaultColor;
}
示例14: CreateResponseFromSession
public static HttpResponseMessage CreateResponseFromSession(Session session)
{
var response = new HttpResponseMessage
{
StatusCode = (HttpStatusCode)session.responseCode
};
var failedHeaders = new List<HTTPHeaderItem>();
foreach (var header in session.oResponse.headers)
{
if (!response.Headers.TryAddWithoutValidation(header.Name, header.Value))
{
failedHeaders.Add(header);
}
}
if (session.ResponseBody.Length > 0)
{
response.Content = new ByteArrayContent(session.ResponseBody);
foreach (var header in failedHeaders)
{
response.Content.Headers.TryAddWithoutValidation(header.Name, header.Value);
}
}
return response;
}
示例15: Handle
public override void Handle(Session Session)
{
GameState state = FFRKProxy.Instance.GameState;
// Win or lose, finishing a battle means it's safe to record that encounter and its drops
// since it won't be possible for the user to have the same drop set if they continue.
if (state.ActiveBattle != null)
{
EventBattleInitiated original_battle = state.ActiveBattle;
state.ActiveBattle = null;
lock (FFRKProxy.Instance.Cache.SyncRoot)
{
DataCache.Battles.Key key = new DataCache.Battles.Key { BattleId = original_battle.Battle.BattleId };
DataCache.Battles.Data data = null;
if (FFRKProxy.Instance.Cache.Battles.TryGetValue(key, out data))
{
data.Samples++;
data.HistoSamples++;
}
}
DbOpRecordBattleEncounter op = new DbOpRecordBattleEncounter(original_battle);
FFRKProxy.Instance.Database.BeginExecuteRequest(op);
FFRKProxy.Instance.RaiseBattleComplete(original_battle);
}
}