基于C#的http协议开发

基于C#的http协议开发

https://www.cnblogs.com/SavionZhang/p/11422481.html

HttpWebRequest、HttpWebResponse头信息获取

string url = "https://hao.360.com/?wd=1000";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

textBox1.AppendText("请求头 \r\n");
textBox1.AppendText("Method:" + req.Method + "\r\n");
foreach (string head in req.Headers.AllKeys)
    textBox1.AppendText(head + "  :  " + req.Headers.Get(head) + "\r\n");

textBox1.AppendText("响应头 \r\n");
foreach (string head in resp.Headers.AllKeys)
    textBox1.AppendText(head + "  :  " + resp.Headers.Get(head) + "\r\n");

 

你可能感兴趣的:(C#)