user81434
user81434

Reputation:

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 way 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.

Upvotes: 4

Views: 950

Answers (1)

Rob Napier
Rob Napier

Reputation: 299265

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.

Upvotes: 5

Related Questions