• http头分析


     
    /***************************************************/
    注意:请求消息也是可以发送实体头域的,见下例(这是一个上传文件的请求)

    // 命令行
    POST /test/upload.asp HTTP/1.1
    // 请求头域
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Referer: http://localhost/test/upload.html
    Accept-Language: zh-cn
    // 实体头域,同时在这里面定义了表单内各个参数的分界符
    Content-Type: multipart/form-data; boundary=---------------------------7d91a15915e6
    //
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;  Embedded Web Browser from: http://bsalsa.com/; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Host: localhost
    // 实体头域
    Content-Length: 0
    Connection: Keep-Alive
    Cache-Control: no-cache
    Cookie: ASPSESSIONIDCCSDBCQQ=DEDDBOJBFHPMGCHEJPLGGLHH
    Authorization: Negotiate TlRMTVNTUAABAAAAB7IIogYABgAqAAAAAgACACgAAAAFASgKAAAAD0hQTVNIT01F
    // 这后面整个部分都是实体信息:
    // 表单参数一:
    -----------------------------7d919f7915e6
    Content-Disposition: form-data; name="file1"; filename="C:\Documents and Settings\Administrator\桌面\系统设计的几点想法.txt"
    Content-Type: text/plain
    1、分析系统的角色,比如系统管理员,用户
    2、分析每类角色的功能需求
    3、从需求中提炼名词,建立词汇表
    4、建立用户模型
    5、系统抽象
    // 表单参数二:
    -----------------------------7d919f7915e6
    Content-Disposition: form-data; name="upload"

    上传
    // 表单参数三:
    -----------------------------7d919f7915e6
    Content-Disposition: form-data; name="post"

    hello
    // 表单结束标记
    -----------------------------7d919f7915e6--
     
    /*******************************************************/
    表单中如果要上传文件,则表单的enctype必须为"multipart/form-data",可能是因为要支持上传
    各种MIME类型的文件,而一般表单提交的时候,其请求头为:
    POST /test/www.sinocoaa.com HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Referer: http://localhost/test/TestFormReqHeader.html
    Accept-Language: zh-cn
    Content-Type: application/x-www-form-urlencoded
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;  Embedded Web Browser from: http://bsalsa.com/; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Host: localhost
    Content-Length: 151
    Connection: Keep-Alive
    Cache-Control: no-cache
    // 实体信息
    dlExamPlan=1&CheckBox2=on&tbUnitCode=fasdf&tbAreaCode=

    asdfasdfasd&tbSchoolCode=fasdfa&btnCreateReport=%E7%

    BB%9F%E8%AE%A1%E6%88%90%E7%BB%A9&CheckBox1=on

    即使没有上传文件输入框,如上例,如果设置了enctype为"multipart/form-data",则请求头就变为如下形式:
    POST /test/www.sinocoaa.com HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-silverlight, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Referer: http://localhost/test/TestFormReqHeader.html
    Accept-Language: zh-cn
    Content-Type: multipart/form-data; boundary=---------------------------7d9251252e0fbc
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;  Embedded Web Browser from: http://bsalsa.com/; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Host: localhost
    Content-Length: 791
    Connection: Keep-Alive
    Cache-Control: no-cache
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="dlExamPlan"

    1
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="CheckBox2"

    on
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="tbUnitCode"

    fasdf
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="tbAreaCode"

    dfasdfasd
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="tbSchoolCode"

    fasdfasd
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="btnCreateReport"

    统计成绩
    -----------------------------7d9251252e0fbc
    Content-Disposition: form-data; name="CheckBox1"

    on
    -----------------------------7d9251252e0fbc--
    /***********************************************************/

  • 相关阅读:
    jquery操作select
    EL表达式
    八大排序算法之希尔排序
    八大排序算法之堆排序
    八大排序算法之归并排序
    yield与send实现协程操作
    详解生成器、迭代器
    类相关知识
    python装饰器大详解
    详解python之反射机制
  • 原文地址:https://www.cnblogs.com/ningj3/p/1416833.html
Copyright © 2020-2023  润新知