POST /index.php HTTP/1.1 |
Host: localhost |
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2 |
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 |
Connection: keep-alive |
Referer: <a target=_blank href="http://localhost/" style="color: rgb(51, 102, 153); text-decoration: none;">http://localhost/</a> |
Content-Length:25 |
Content-Type:application/x-www-form-urlencoded |
|
username=aa&password=1234 |
--------------------------------------------------------------------------- |
HTTP/1.1 200 OK |
Server: Microsoft-IIS/5.1 |
Date: Mon, 06 Mar 2006 12:52:44 GMT |
X-Powered-By: ASP.NET |
Content-Length: 20 |
Content-Type: text/html |
Cache-control: private |
|
<p>this is 1.htm</p> |
----------------------------------------------------------------- |
GET 请求获取由 Request-URI 所标识的资源 |
POST 请求服务器接收在请求中封装的实体,并将其作为由 Request-Line 中的 Request-URI 所标识的资源的一部分 |
HEAD 请求获取由 Request-URI 所标识的资源的响应消息报头 |
PUT |
请求服务器存储一个资源,并用 Request-URI 作为其标识符 |
DELETE 请求服务器删除由 Request-URI 所标识的资源 |
TRACE 请求服务器回送到的请求信息,主要用于测试或诊断 |
CONNECT 保留将来使用 |
OPTIONS 请求查询服务器的性能,或者查询与资源相关的选项和需求 |
----------------------------------------------------------------- |
text/html HTML文本 |
text/plain:普通文本 |
image/jpeg JPG图片 |
image/gif GIF图片 |
application/xml XML文档 |
audio/x-mpegurl MP3文件列表,如果安装了Winamp,则可以直接把它当面M3U文件来打开 |
----------------------------------------------------------------- |
Content-Type:application/x-www-form-urlencoded |
和 |
Content-Type:multipart/related |
application/x-www-form-urlencoded: 窗体数据被编码为名称/值对。这是标准的编码格式。 multipart/form-data: 窗体数据被编码为一条消息,页上的每个控件对应消息中的一个部分。 text/plain: 窗体数据以纯文本形式进行编码,其中不含任何控件或格式字符。 |
补充 |
form的enctype属性为编码方式,常用有两种:application/x-www-form-urlencoded和multipart/form-data,默认为application/x-www-form-urlencoded。 当action为get时候,浏览器用x-www-form-urlencoded的编码方式把form数据转换成一个字串(name1=value1&name2=value2...),然后把这个字串append到url后面,用?分割,加载这个新的url。 当action为post时候,浏览器把form数据封装到http body中,然后发送到server。 如果没有type=file的控件,用默认的application/x-www-form-urlencoded就可以了。 但是如果有type=file的话,就要用到multipart/form-data了。浏览器会把整个表单以控件为单位分割,并为每个部分加上Content-Disposition(form-data或者file),Content-Type(默认为text/plain),name(控件name)等信息,并加上分割符(boundary)。 |
------------------------------------------------------------- |
post提交文件的完整请求 |
POST / HTTP/1.1 |
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */* |
Accept-Language: zh-CN |
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; 2345Explorer/8.4.1.14855) |
Content-Type: multipart/form-data; boundary=---------------------------7e122f37c09c2 |
Accept-Encoding: gzip, deflate |
Host: baidu.com |
Content-Length: 2900 |
Connection: Keep-Alive |
Cache-Control: no-cache |
Cookie: JSESSIONID=C97BF0B82FD824955123B82682188CC0; j_username=super |
-----------------------------7e122f37c09c2 |
Content-Disposition: form-data; name="mytext" |
helloword |
-----------------------------7e122f37c09c2 |
Content-Disposition: form-data; name="myfile"; filename="C:\Users\Administrator\Desktop\鍩虹鐭ヨ瘑.txt" |
Content-Type: text/plain |
String result = String.format("%.2f", 3.1415926); // %.2f %. 表示 小数点前任意位数 2 表示两位小数 格式后的结果为f 表示浮点型。 |
String str = new String("你好".getBytes("ISO-8859-1"),"ISO-8859-1"); |
/^[\u4e00-\u9fa5]$/ |
-----------------------------7e122f37c09c2-- |
by: 发表于:2017-09-07 15:50:09 顶(0) | 踩(0) 回复
??
回复评论