public void parseHTTPData(TcpPacket packet) { bool IsSend = true; bool IsPOST = true; string s = Encoding.GetEncoding("utf-8").GetString(packet.PayloadData); string[] ss = s.Split(new char[] { '\r', '\n' }); Hashtable header = new Hashtable(); for (int i = 0; i < ss.Length; i++) { if (i == 0) { if (ss[i].StartsWith("GET")) { IsPOST = false; header.Add("url", ss[i].Split(' ')[1]); } else if (ss[i].StartsWith("POST")) { IsPOST = true; header.Add("url", ss[i].Split(' ')[1]); } else { IsSend = false; } } if (ss[i].IndexOf(":") > 0) { string[] sss = ss[i].Split(':'); try { header.Add(sss[0].Trim(), sss[1].Trim()); } catch (ArgumentException e) { Console.Write("same key!"); } } } if (IsSend) { OutPut("Method:" + (IsPOST ? "POST" : "GET") + " http://" + header["Host"] + header["url"]); } else { OutPut("Receive data."); } OutPut("=========================================================================="); int dataindex = GetIndexOf(packet.PayloadData, new byte[] { 0xd, 0xa, 0xd, 0xa }); if (dataindex >= 0) { byte[] data = new byte[packet.PayloadData.Length - dataindex - 4]; Array.Copy(packet.PayloadData, dataindex + 4, data, 0, data.Length); OutPut(Inspector.Inspect(data)); } else { OutPut(Inspector.Inspect(packet.PayloadData)); } }
public static void DataInfo(TcpPacket packet) { OutPut(Inspector.Inspect(packet.PayloadData, ShowHex, ShowChar)); }