Fiddler コア .NET ライブラリをローカル プロキシとして使用して、Web でのユーザー アクティビティを記録していました。しかし、私は解決するのが汚いと思われる問題に行き着きました。私は Google Chrome という Web ブラウザーを持っており、ユーザーはそれぞれ異なる Web URL を持つ 10 個の異なるタブのように開きました。問題は、プロキシが各ページによって開始されたすべての HTTP セッションを個別に記録することです。これにより、対応する HTTP セッションが属しているタブを知性を使用して把握できます。これは、HTTP プロトコルのステートレスな性質によるものだと理解しています。しかし、これを行う簡単な方法があるかどうか疑問に思っていますか?私はフィドラーでそのための以下のC#コードになりました。それでも、それは信頼できる解決策ではありません。
これは、.NET 4 用の Fiddler コアにバンドルされているサンプル プロジェクトを変更したものです。基本的には、最後の数秒間に開始された HTTP セッションをフィルター処理して最初の要求を見つけるか、ブラウザーの同じタブで作成された別のページに切り替えます。それはほとんど機能しますが、普遍的な解決策ではないようです。
Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
{
//exclude other HTTP methods
if (oS.oRequest.headers.HTTPMethod == "GET" || oS.oRequest.headers.HTTPMethod == "POST")
//exclude other HTTP Status codes
if (oS.oResponse.headers.HTTPResponseStatus == "200 OK" || oS.oResponse.headers.HTTPResponseStatus == "304 Not Modified")
{
//exclude other MIME responses (allow only text/html)
var accept = oS.oRequest.headers.FindAll("Accept");
if (accept != null)
{
if(accept.Count>0)
if (accept[0].Value.Contains("text/html"))
{
//exclude AJAX
if (!oS.oRequest.headers.Exists("X-Requested-With"))
{
//find the referer for this request
var referer = oS.oRequest.headers.FindAll("Referer");
//if no referer then assume this as a new request and display the same
if(referer!=null)
{
//if no referer then assume this as a new request and display the same
if (referer.Count > 0)
{
//lock the sessions
Monitor.Enter(oAllSessions);
//filter further using the response
if (oS.oResponse.MIMEType == string.Empty || oS.oResponse.MIMEType == "text/html")
//get all previous sessions with the same process ID this session request
if(oAllSessions.FindAll(a=>a.LocalProcessID == oS.LocalProcessID)
//get all previous sessions within last second (assuming the new tab opened initiated multiple sessions other than parent)
.FindAll(z => (z.Timers.ClientBeginRequest > oS.Timers.ClientBeginRequest.AddSeconds(-1)))
//get all previous sessions that belongs to the same port of the current session
.FindAll(b=>b.port == oS.port ).FindAll(c=>c.clientIP ==oS.clientIP)
//get all previus sessions with the same referrer URL of the current session
.FindAll(y => referer[0].Value.Equals(y.fullUrl))
//get all previous sessions with the same host name of the current session
.FindAll(m=>m.hostname==oS.hostname).Count==0 ) //if count ==0 that means this is the parent request
Console.WriteLine(oS.fullUrl);
//unlock sessions
Monitor.Exit(oAllSessions);
}
else
Console.WriteLine(oS.fullUrl);
}
else
Console.WriteLine(oS.fullUrl);
Console.WriteLine();
}
}
}
}
};