ASIHTTPRequest请求时,发送了2次请求问题解决
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ASIHTTPRequest请求时,发送了2次请求问题解决,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1645字,纯文字阅读大概需要3分钟。
内容图文
![ASIHTTPRequest请求时,发送了2次请求问题解决](/upload/InfoBanner/zyjiaocheng/531/fe17b779bb604d6db604c07c63b27785.jpg)
后来组内老大网上找到答案,这是stackoverflow上分享的一段话(地址:http://stackoverflow.com/questions/8317662/asihttprequest-request-sent-twice) This has bitten me too. I was using a GET request to validate a multi-use voucher code on a ser
后来组内老大网上找到答案,这是stackoverflow上分享的一段话(地址:http://stackoverflow.com/questions/8317662/asihttprequest-request-sent-twice)
This has bitten me too. I was using a GET request to validate a multi-use voucher code on a server. When we added a rate limitation for redeeming codes some customers reported hitting the limit before they should have. Turns out that some of the validations triggered two redeems.
Your request is using the GET method.
The default behavior when using GET is to allow persistent connections (the Keep-Alive HTTP header).
When using a persistent connection your GET request might get retransmitted if something on the network looks wonky (that's a technical term) instead of the request just failing. This is usually desirable because GET requests often do not have any side effects on the server.
POST or PUT requests on the other hand default to not use a persistent connection and will not retransmit your operation, which could well be a credit card purchase or something else with significant side effects.
If you wish to prevent your ASIHTTPRequest GET sometimes sending 2 or more server requests (due to network issues outside your control) you can simply set this flag:
request.shouldAttemptPersistentConnection=
NO;
This
should take care of the spurious GET duplicates on the server.
内容总结
以上是互联网集市为您收集整理的ASIHTTPRequest请求时,发送了2次请求问题解决全部内容,希望文章能够帮你解决ASIHTTPRequest请求时,发送了2次请求问题解决所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。