The status code 0 in the NSHTTPURLResponse object usually means that there was no response, and can occur for various reasons. The server will never return status 0, as this is not a valid HTTP status code.
In your case, you get a status code of 0 because the request is a timeout, and 0 is only the default value for the property. The timeout by itself can be for various reasons, for example, the server simply does not respond on time, is blocked by a firewall, or the entire network connection is disconnected. Usually in the case of the latter, although the phone is smart enough to know that it does not have a network connection, it will work immediately. However, it will still work with an explicit status code of 0.
Note that in cases where the status code is 0, the real error is fixed in the returned NSError object, and not in NSHTTPURLResponse .
The status of HTTP 408 quite rare in my experience. I have never come across this myself. But, apparently, it is used in cases where the client needs to maintain an active connection from the socket to the server, and the server expects the client to send more data through the open socket, but this is not done at the specified time and the server ends the connection with the 408 status code. essentially telling the customer "you take too long."
devios1 Apr 27 '15 at 23:08 2015-04-27 23:08
source share