相信很多朋友会遇到:使用ASIHTTPRequest GET请求时,发送了2次(即重复发送了1次)
由于之前的app都对失败,没有非常重要的要求,因此,也从没留意这个问题。这次产品升级,增加了一些新的需求,这些需求又恰好对这个要求较高,为这个问题纠结了一段时间
后来组内老大网上找到答案,这是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.
分享到:
相关推荐
iOS ASIHttpRequest 请求https
在网络访问时,一般都建议用异步访问,但是异步访问的话,需要传入delegate,并处理回调。不利于将所有的网络访问的方法集中到一个类中,所以我采用同步访问的方式。后来产品部们要求网络访问可以取消,但是ASIHTTP ...
ASIHTTPRequest网络请求集合,直接引入到项目中使用。
ASIHttpRequest是iOS开发必备的网络数据请求包,使用方便,唯一的缺点是非ARC的,需要设置项目中的非ARC类
使用iOS SDK中的HTTP网络请求API,ASIHTTPRequest就是一个对CFNetwork API进行了封装,并且使用起来非常简单的一套API,
全称是ASIHTTPRequest,外号“HTTP终结者”,可以实现http网络请求,功能十分强大。
ASIHTTPRequest,用于获取下载及其相关处理与应用的功能函数
前言 使用 iOS SDK 中的 HTTP 网络请求 API,相当的复杂,调用很繁琐,...可惜作者早已停止更新,有一些潜在的 BUG 无人去解决,很多公司的旧项目里面都残留着它的身影,以前的很多 iOS 项目都是 ASI + SBJson,会不
ios开发框架 ASIHttpRequest 资源来源于网上 非原创
ASIHTTPRequest 源码 、底层构架
asihttprequest是目前做移动平台游戏上比较便捷的http通信第三方库
ASIHTTPRequest是简单易用的,它封装了CFNetwork API。使得与Web服务器通信变得更简单。它是用Objective-C编写的,可以在MAC OS X和iPhone应用中使用。 它适用于执行基本的HTTP请求和互动(或者说是反馈)。...
ASIHTTPRequest使用介绍
ASIHTTPRequest实现资源的下载,断点续传
iphone 网络请求 类库 网络处理api iphone 开发必备类库程序源代码
此为ASIHTTPRequest打包的Frameword,直接导入到工程即可使用。