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  包含此软件的额外信息

  • 相关阅读:
    ubuntu 完全干净的卸载docker
    thinkphp5 助手函数input的常用方法
    thinkphp6
    docker编排
    Linux下的tar压缩解压缩命令详解
    scp拷贝命令
    一行命令搞定node.js 版本升级
    git 设置文件大小写敏感
    ubuntu1804php安装
    关于权限表的基本设计
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/1578760.html
Copyright © 2011-2022 走看看