开发者

Can I get the status text from an NSHTTPURLResponse?

If I use NSURLConnection to get data from a server and it sends back a response that begins with, say:

HTTP/1.1 406 Some string of text here

Is there any w开发者_如何学JAVAay I can retrieve the status text "Some string of text here"? I know how to get the status code, and I know about localizedStringForStatusCode:, but in this case I need access to the specific text sent back.


You can use ASIHTTPRequest, which provides this as -requestStatusMessage. Or you can use Core Foundation's CFHTTP, which provides CFHTTPMessageCopyResponseStatusLine. I don't believe there's a good way to get to the CFHTTPMessage from NSHTTPURLResponse unfortunately. Of course, ASIHTTPRequest is pretty awesome anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜