【发布时间】:2012-07-08 16:28:03
【问题描述】:
这是我的监控 Http 代码:
static void Main(string[] args)
{
try
{
byte[] input = BitConverter.GetBytes(1);
byte[] buffer = new byte[4096];
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
s.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 80));
s.IOControl(IOControlCode.ReceiveAll, input, null);
s.BeginReceive(arrResponseBytes, 0, arrResponseBytes.Length, SocketFlags.None, new AsyncCallback(OnClientReceive), s);
System.Threading.ManualResetEvent reset = new System.Threading.ManualResetEvent(false);
reset.WaitOne();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Console.ReadKey();
}
static byte[] arrResponseBytes = new byte[1024 * 5];
protected static void OnClientReceive(IAsyncResult ar)
{
Socket socket = (Socket)ar.AsyncState;
int count = socket.EndReceive(ar);
if (count > 0)
{
Console.WriteLine(Encoding.ASCII.GetString(arrResponseBytes, 0, count));
socket.BeginReceive(arrResponseBytes, 0, arrResponseBytes.Length, SocketFlags.None, new AsyncCallback(OnClientReceive), socket);
}
}
但我无法获取 http 主机。 不知道什么数据。 我想获取 http 主机,例如: http://google.com 我如何监控系统http? 谢谢。
【问题讨论】:
-
你试过解压吗?可以在服务器端进行压缩(由标头告知),然后您只会看到垃圾。无论如何,我不确定您是否可以区分不同的请求,但正如我所说,我不确定这是否会成为问题。
-
fiddler 软件怎么样?我想获取浏览器响应。
-
我正在使用fiddler2.com/fiddler2 - 只要其他人可能对它了解更多,或者我绝对错过了一个功能,我就不会重新发明轮子。顺便说一句:Fiddler 作为代理工作
-
关于:https 有点困难:你需要伪造一个证书(中间的那种人),这会点亮浏览器上的典型警告