110,534
社区成员
发帖
与我相关
我的任务
分享
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string header1="GET /news/ah.html HTTP/1.1"
+"HOST: ss.xom "
+"Accept:*/* "
+"Referer: http://ss.xom:8080/NN/A.HTML "
+"Content-Length: 156831 "
+"………… "
+"………… "
+"X_Forwarded_for: 127.0.0.1 "
+"………… "
+"………… ";
string header2="POST http://ss.xom/HH HTTP/1.1 "
+"HOST: ss.xom:8080 "
+"Accept:*/* "
+"Referer: http://ss.xom:8080/NN/A.HTML "
+"Content-Length: 156831 "
+"………… "
+"………… "
+"X_Forwarded_for: 192.168.0.9,127.0.0.1,172.168.0.5 "
+"………… "
+"………… ";
TestHeader(header1);
Response.Write("<hr color='blue'>\n");
TestHeader(header2);
}
private void TestHeader(string strHeader)
{
string sxGet = @"(?<oGet>GET\s+(?<vURI>[\/\.\w]+))\s*";
string sxPost = @"(?<oPost>POST\s+(?<vURL>http\:\/\/[\/\.\w]+))\s*";
string sxHost = @"(?<oHost>HOST\:\s+(?<vHost>[\/\.\w]+(\:\d+)?))\s*";
string sxAgent = @"(?<oAgent>X_Forwarded_for\:\s+(?<vIP>[\d\.\,]+))\s*";
System.Text.RegularExpressions.Match mResult;
mResult = System.Text.RegularExpressions.Regex.Match(strHeader, sxGet);
if (mResult.Success)
{
Response.Write(mResult.Value + "<br>");
Response.Write("vURI="+ mResult.Groups["vURI"].Value + "<hr>\n");
}
mResult = System.Text.RegularExpressions.Regex.Match(strHeader, sxPost);
if (mResult.Success)
{
Response.Write(mResult.Value + "<br>");
Response.Write("vURL="+ mResult.Groups["vURL"].Value + "<hr>\n");
}
mResult = System.Text.RegularExpressions.Regex.Match(strHeader, sxHost);
if (mResult.Success)
{
Response.Write(mResult.Value + "<br>");
Response.Write("vHost="+ mResult.Groups["vHost"].Value + "<hr>\n");
}
mResult = System.Text.RegularExpressions.Regex.Match(strHeader, sxAgent);
if (mResult.Success)
{
Response.Write(mResult.Value + "<br>");
Response.Write("vIP="+ mResult.Groups["vIP"].Value + "<hr>\n");
}
}
GET /news/ah.html <br>vURI=/news/ah.html<hr>
HOST: ss.xom <br>vHost=ss.xom<hr>
X_Forwarded_for: 127.0.0.1 <br>vIP=127.0.0.1<hr>
<hr color='blue'>
POST http://ss.xom/HH <br>vURL=http://ss.xom/HH<hr>
HOST: ss.xom:8080 <br>vHost=ss.xom:8080<hr>
X_Forwarded_for: 192.168.0.9,127.0.0.1,172.168.0.5 <br>vIP=192.168.0.9,127.0.0.1,172.168.0.5<hr>