ASIHTTPRequest 之 shouldUseRFC2616RedirectBehaviour

Handling redirection

ASIHTTPRequest will automatically redirect to a new URL when it encounters one of the following HTTP status codes, assuming a Location header was sent:

  • 301 Moved Permanently
  • 302 Found
  • 303 See Other

When redirection occurs, the value of the response data (responseHeaders / responseCookies / responseData / responseString etc) will reflect the content received from the final location.

Cookies set on any of the urls encountered during a redirection cycle will be stored in the global cookie store, and will be represented to the server on the redirected request when appropriate.

You can turn off automatic redirection by setting the request’s shouldRedirect property to NO.

By default, automatic redirects always redirect using a GET request (with no body). This behaviour matches the way most browsers work, not the HTTP spec, which specifies that 301 and 302 redirects should use the original method.

To preserve the original method (including the request body) for 301 and 302 redirects, setshouldUseRFC2616RedirectBehaviour to YES on the request before you start it.


这个属性的意思是,ASIHTTPRequest 默认会自动帮你 redirection,但是默认是用 "GET" 的方式,如果你的 request 是 Post,那么你要把 setshouldUseRFC2616RedirectBehaviour to YES 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值