We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
因为GET请求只能进行url编码,所以在使用get方法发送请求的时候,如果参数是数组的情况,需要注意转码问题。例如:
let params = { refundArry: [1,2], statusArry: [1,2] } $http({ 'method': 'GET', 'url': babala, 'params': params, })
refundArry:1 refundArry:0 statusArry:0 statusArry:-1 type:1 uid:64
这一定不是我们想要的,所以一定要经过下面的方式转换:
let params = { refundArry: [1,2], statusArry: [1,2] } // 将数组转化成字符串,但是形似数组,例如:[1,2]=> "[1,2]" let param = {} for(var key in params) { if (angular.isArray(params[key])) { param[key] = `[ ${params[key]} ]` } else { param[key] = params[key] } } $http({ 'method': 'GET', 'url': babala, 'params': param, })
refundArry:[1,2] statusArry: [1,2] type:1 uid:64
这样就是我们想要的结果了
参数大小的限制又是从哪来的呢?
GET和POST还有一个重大区别,GET产生一个TCP数据包;POST产生两个TCP数据包。
对于GET方式的请求,浏览器会把http header和data一并发送出去,服务器响应200(返回数据);
而对于POST,浏览器先发送header,服务器响应100 continue,浏览器再发送data,服务器响应200 ok(返回数据)。
据研究,在网络环境好的情况下,发一次包的时间和发两次包的时间差别基本可以无视。而在网络环境差的情况下,两次包的TCP在验证数据包完整性上,有非常大的优点。
并不是所有浏览器都会在POST中发送两次包,Firefox就只发送一次。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
普通常见的区别
区别详解
1. 对于第四条
因为GET请求只能进行url编码,所以在使用get方法发送请求的时候,如果参数是数组的情况,需要注意转码问题。例如:
Quert String Parameters
这一定不是我们想要的,所以一定要经过下面的方式转换:
Quert String Parameters
这样就是我们想要的结果了
2. 对于第六条
参数大小的限制又是从哪来的呢?
GET和POST还有一个重大区别,GET产生一个TCP数据包;POST产生两个TCP数据包。
对于GET方式的请求,浏览器会把http header和data一并发送出去,服务器响应200(返回数据);
而对于POST,浏览器先发送header,服务器响应100 continue,浏览器再发送data,服务器响应200 ok(返回数据)。
据研究,在网络环境好的情况下,发一次包的时间和发两次包的时间差别基本可以无视。而在网络环境差的情况下,两次包的TCP在验证数据包完整性上,有非常大的优点。
并不是所有浏览器都会在POST中发送两次包,Firefox就只发送一次。
![image](https://user-images.githubusercontent.com/9944527/38073076-102faf24-335c-11e8-9c46-eed09acb12f2.png)
![image](https://user-images.githubusercontent.com/9944527/38073085-18ff60c2-335c-11e8-91b7-a7e1acdcedec.png)
The text was updated successfully, but these errors were encountered: