一,GET请求
1)完整的地址
一个完整的URL地址:
http://host:port/path?aaa=111&bbb=222…
http :协议类型
host :服务器IP地址或者是域名
port :端口号,默认是80,如果是别的需要写上去,像172.43.0.55:8888
path :请求资源的路径
? :分割线,后面的就是参数了
& :多个参数的链接符号
2)参数
在URL里面请求参数一般叫params,在fiddler里是这个:
3)UrlEncode编码
有些URL地址带中文,是被编码过的,长这样:
%E4%B8%8A%E6%B5%B7%E6%
可以用在线编码/解码工具:http://tool.chinaz.com/tools/urlencode.aspx
二,POST请求
1)POST参数
POST参数的形式和GET有些不同:
- 可以放在URL里
- 可以放在body里
- 可以同时放在URL和body里
- 可以不带参数
- 一般情况下,习惯将参数放到body里
2)body数据类型
常见的四种类型数据:
application/json
application/x-www-form-urlencoded
multipart/form-data
text/xml
1,application/json :最常见且友好的格式
2,application/x-www-form-urlencoded
浏览器的原生 form 表单,如果不设置 enctype 属性,那么最终就会以 application/x-www-form-urlencoded 方式提交数
input1=xxx&input2=ooo&remember=false
3,multipart/form-data
这一种是表单格式的,数据类型如下:
——WebKitFormBoundaryrGKCBY7qhFd3TrwA Content-Disposition: form-data; name=”text”title——WebKitFormBoundaryrGKCBY7qhFd3TrwA Content-Disposition: form-data; name=”file”; filename=”chrome.png” Content-Type: image/png PNG … content of chrome.png …——WebKitFormBoundaryrGKCBY7qhFd3TrwA–
4,text/xml