C# Http Response Header 打印

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("****************************************************************\n");
            Console.WriteLine("Http Response Header Resolver V1.00.00\n");
            Console.WriteLine("input a url for example:www.google.com\n");
            Console.WriteLine("input q to quit the program\n");
            Console.WriteLine("****************************************************************\n");

            while(true)
            {
                Console.Write(">");
                string url = Console.ReadLine();

                if(url=="q")
                {
                    break;
                }

                try
                {

                    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://" + url);
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                    //协议版本号,状态码,状态描述
                    Console.WriteLine(String.Format("{0,-20}HTTP/{1} {2:d} {3}","(Status-Line)",response.ProtocolVersion,response.StatusCode,response.StatusDescription));
                    
                    //Http response头
                    for(int i=0;i

  

转载于:https://www.cnblogs.com/oyjj/archive/2011/09/02/2164417.html

你可能感兴趣的:(C# Http Response Header 打印)