如何从iOS检查http请求响应状态代码? [英] how do I check an http request response status code from iOS?

查看:184
本文介绍了如何从iOS检查http请求响应状态代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 NSURLConnection NSURLRequest 课程。

如何读取响应的状态,即app引擎使用 response.set_status设置的值(200,message =Success)例如?

How do I read the response's status, i.e. the value set by app engine using response.set_status(200, message="Success") for instance?

收到 NSURLConnection的 <$ c后,我无法找到可以读取这些状态代码的位置$ c> connectionDidFinishLoading 委托客户端的委托。

I'm not able to find where I can read these status codes once I receive the NSURLConnection's connectionDidFinishLoading delegate call on the client end.

推荐答案

connection:didReceiveResponse:在收到响应时调用delegate方法,这会给你一个 NSURLResponse 来玩。

The connection:didReceiveResponse: delegate method is called when a response is received, which gives you an NSURLResponse to play with.

如果您发出了HTTP请求,那么它实际上是一个 NSHTTPURLResponse 对象,它有一个 statusCode 方法。

If you've made an HTTP request, then it'll actually be an NSHTTPURLResponse object, which has a statusCode method.

这篇关于如何从iOS检查http请求响应状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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