NSURLConnection和keep-alive [英] NSURLConnection and keep-alive

查看:271
本文介绍了NSURLConnection和keep-alive的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用NSURLConnection的客户端应用程序中有一个小错误。我已经跟踪到一个意外的连接保持活动,似乎混淆了Web服务器(可能是服务器端的一个错误)。解决方法是在某一点强制关闭所有未完成的连接。我可以通过NSURLConnection,也就是像




[NSURLConnection closeAllIdleConnections]

解决方案

ASIHTTPRequest 有一个expirePersistentConnections方法。它可以做你想要的东西。



这不是NSURLConnection的替代,但是将代码从NSURLConnection移植到ASIHTTPRequest并不难。 p>

I have a small bug in my client app that uses NSURLConnection. I have tracked it down to an unexpected connection keep-alive that seems to confuse the web server (probably a bug on the server side). The workaround would be to force-close all outstanding connections at a certain point. Can I do this somehow with NSURLConnection, i.e. something like

[NSURLConnection closeAllIdleConnections];

解决方案

ASIHTTPRequest has an expirePersistentConnections method. It may do what you're looking for.

It's not a drop-in replacement for NSURLConnection, but it's not too hard to port code from NSURLConnection to ASIHTTPRequest.

这篇关于NSURLConnection和keep-alive的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆