日期:2014-05-17  浏览次数:20933 次

浏览器是怎样处理表单的?
浏览器是怎样分析识别表单的各个元素,然后确定发送的题头和内容的?
比如这个表单提交的数据包:
C/C++ code
POST /account/edit_reg.htm HTTP/1.1
Host: www.eceurope.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; zh-CN; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.eceurope.com/account/edit_reg.htm?session=&
Cookie: referrer=http%3A%2F%2Fwww.b2b99.com%2Fworldb2b.htm; test=1; __utma=201624837.37668972.1209714802; __utmb=201624837; __utmc=2016248; __utmz=201624837.1.1.utmccn=(referral)|utmcsr=b2b99.com|utmcct=/worldb2b.htm|utmcmd=referral
Content-Type: application/x-www-form-urlencoded
Content-Length: 292

session=&email=wang%40gmail.com&password=666666&passwordconfirm=666666&&name=kevincity=beijing&country=CN&fax=&url=&partner_share=Yes&terms=yes&submit=Proceed

这样一个表单提交数据包,我想知道浏览器是怎样确定发送标题需要Accept:、Accept-Language:、Accept-Encoding:等等这些项目的,不同的表单提交这些标题项目好像并不一样,浏览器是怎样确定的;
另外浏览器是怎样分析html文件并确定发送内容部分的?

------解决方案--------------------
POST方法会将本表单的名称/值对保存在http的头部分,即可达到传递用户填写的表单值的目的。
Accept:、Accept-Language:、Accept-Encoding等项目是HTML的head部分确定的。
------解决方案--------------------
hidden元素当然要提交,只是不显示在页面上。
------解决方案--------------------
hidden元素可以传一些比较私话或有用的信息给服务器,用户不用知道的那种。