zoukankan      html  css  js  c++  java
  • HttpWebRequest.Method属性研究

    编者按:通过此以下程序的调用,让我们明白在程序读取一个页面的时候,都从头(Head)里面读取到了什么!
    using System;

    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DownloadFile_help2
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Net.HttpWebRequest hwr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://210.45.192.243/jyzd");

                 hwr.Method = "GET";
                // (msdn标注) Method 属性只能设置为 GET 和 POST 方法。任何其他 HTTP 1.1 或 1.0 协议谓词(例如,HEAD、PUT、DELETE、TRACE 或 OPTIONS)都将引发 NotSupportedException 异常。

                System.Net.WebResponse response = hwr.GetResponse();

                string[] str = response.Headers.AllKeys;
                foreach (string temp in str)
                {
                    Console.Write("{0} {1} ", temp, temp.Length);
                    Console.WriteLine("{0}", response.Headers[temp]);
                }
            }
        }
    }

    //输出结果
    //Content-Length 14 252607 字节流的长度,即当前页面的大小
    //Cache-Control 13 private   指示客户端应该如何缓存改内容
    //Content-Type 12 text/html; charset=gb2312           ContentType 属性包含请求的媒体类型
    //Date 4 Wed, 07 Oct 2009 06:31:24 GMT 获取此页面时的服务器时间
    //Server 6 Microsoft-IIS/6.0  服务器类型
    //X-AspNet-Version 16 2.0.50727 版本
    //X-Powered-By 12 ASP.NET  包含此软件的额外信息

  • 相关阅读:
    mysql高效分页
    mybatis插入值为空时需要制定类型
    NoClassDefFoundError
    mybatis动态sql中的两个内置参数(_parameter和_databaseId)
    Java位运算在程序设计中的使用:位掩码(BitMask)
    基于netty的聊天室(保持和获取客户端channel)
    Netty自定义协议半包编解码
    位运算基础
    JAVA加密系列(四)- 位运算加密(异或加密)
    位运算基础
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/1578760.html
Copyright © 2011-2022 走看看