Mega Code Archive

 
Categories / C# Tutorial / Network
 

Examine the headers

using System;  using System.Net;    class MainClass {     public static void Main() {        HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://www.rntsoft.com");        HttpWebResponse resp = (HttpWebResponse) req.GetResponse();        string[] names = resp.Headers.AllKeys;        Console.WriteLine("{0,-20}{1}\n", "Name", "Value");      foreach(string n in names)        Console.WriteLine("{0,-20}{1}", n, resp.Headers[n]);        resp.Close();    }  } Name Value Connection close Accept-Ranges bytes Content-Length 341387 Content-Type text/html Date Sun, 25 Mar 2007 21:06:43 GMT ETag "14904bc-5358b-bce5400" Last-Modified Tue, 20 Feb 2007 15:25:04 GMT Server Apache/2.0.54 (Fedora)