ASIHTTPRequest请求时,发送了2次请求问题解决

WBOY
풀어 주다: 2016-06-07 15:37:35
원래의
1175명이 탐색했습니다.

后来组内老大网上找到答案,这是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:

<span>request</span><span>.</span><span>shouldAttemptPersistentConnection</span><span>=</span><span> NO</span><span>;</span>

<span><span>This should take care of the spurious GET duplicates on the server.</span><br> </span>

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!