1.HTTP 是如何提交表单的
<form>标签的属性enctype设置以何种编码方式提交表单数据。可选的值有三个:
application/x-www-form-urlencoded:
这是默认的编码方式。它只处理表单域里的value属性值,采用这种变法方式的表单会将表单域的值处理成URL方式。
multipart/form-data:
这种编码方式会以二进制流的方式来处理表单数据,这中编码方式会把文件域指定的文件内容也封装到请求参数里。
text/plain:
这种方式当表单的action属性值为mailto:URL的形式时比较方便,这种方式主要适用于直接通过表单发送邮件。
以上form表单的enctype属性的值决定了浏览器的行为 ,对应于http协议 ,如果选择'application/x-www-form-urlencoded' 编码,http的请求头会有如下
Request Headers From Upload Stream
Content-Type application/x-www-form-urlencoded
Content-Type application/x-www-form-urlencoded
关于application/x-www-form-urlencoded
This is the default content type. Forms submitted with this content type must be encoded as follows:
- Control names and values are escaped. Space characters are replaced by `+' , and then reserved characters are escaped as described in [RFC1738] , section 2.2: Non-alphanumeric characters are replaced by `%HH' , a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A' ).
- The control names/values are listed in the order they appear in the document. The name is separated from the value by `=' and name/value pairs are separated from each other by `&' .
参考:http://www.w3.org/TR/html401/interact/forms.html |