5.9  Verify Status Codes

The response from a website to a request for a bookmark’s URL normally contains an HTTP Status Code, which is usually a positive integer between 100 and 599, although some creative cowboy webmasters sometimes return their own made-up status codes, usually in the range 600 to 999.

However, “lower level” errors can occur if the site does not send an HTTP response.  These lower level errors are returned to BookMacster by Mac OS X and contain “error codes” in Apple’s NSURLErrorDomain.  The codes in NSURLErrorDomain are negative numbers.

Fortunately (maybe because Apple planned it this way), there is no overlap between these positive and negative values.  Therefore, BookMacster stores in its Verify results for a bookmark what we call a Verify Status Code.  Quite simply, if this value is positive, it’s an HTTP Status Code, and if negative, it’s an error code in the NSURLErrorDomain.

5.9.1  Verify Status Codes for Positive Values (HTTP Status Codes)

Most of the HTTP status codes you will see are defined in Section 10 of Internet Society’s specification HTTP/1.1.  But although it was published in 1999, this document still has not been ratified into a standard, and in the meantime additional codes have been proposed.  For a readable and more complete table of the HTTP status codes in use at this time, we recommend this Wikipedia article.

5.9.2  Verify Status Codes for Negative Values (NSURLErrorDomain)

The following is derived from the file NSURLErrorDomain.h, but we’ve published them here since you will not have that file unless you have installed Apple’s Developer Tools, and also we added the narrative descriptions.


CodeNSURLError:Means that connection failed because:
-999Cancelledit was cancelled.
-1000BadURLit has a bad URL.
-1001TimedOutit took longer than the timeout which was alotted.
-1002UnsupportedURLit has an unsupported URL.
-1003CannotFindHostthe host could not be found.
-1004CannotConnectToHostthe host would not let us establish a connection.
-1005NetworkConnectionLostwe established a connection but it was lost.
-1006DNSLookupFaileddomain name server (DNS) lookup failed.
-1007HTTPTooManyRedirectswe received too many redirects from the server while processing the request.
-1008ResourceUnavailablethe requested resource is not available.
-1009NotConnectedToInternetthis computer appears to not have an internet connection.
-1010RedirectToNonExistentLocationwe were redirected to a nonexistent location.
-1011BadServerResponsewe got a bad response from the server.
-1012UserCancelledAuthenticationthe user cancelled when asked for authentication.
-1013UserAuthenticationRequireduser authentication is required.
-1014ZeroByteResourcethe requested resource contains no data.
-1015CannotDecodeRawDatawe could not decode the raw data.
-1016CannotDecodeContentDatawe could not decode the content.
-1017CannotParseResponsewe could not parse the response.
-1100FileDoesNotExistthe requested file does not exist.
-1101FileIsDirectorythe requested file is in fact a directory.
-1102NoPermissionsToReadFilewe lack sufficient permissions to read the requested file.
-1103DataLengthExceedsMaximumthe length of the requested data exceeds the limit.
-1200SecureConnectionFailedwe could not establish a secure connection.
-1201ServerCertificateHasBadDatethe server’s SSL certificate appears to have expired.
-1202ServerCertificateUntrustedthe server’s SSL certificate is not trusted.
-1203ServerCertificateHasUnknownRootthe server’s SSL certificate has an unknown root.
-1204ServerCertificateNotYetValidthe server’s SSL certificate is not yet valid.
-1205ClientCertificateRejectedthe server rejected our client certificate.
-2000CannotLoadFromNetworkwe could not load from the network.
-3000CannotCreateFilewe could not create a file.
-3001CannotOpenFilewe could not open a file.
-3002CannotCloseFilewe could not close a file.
-3003CannotWriteToFilewe could not write to a file.
-3004CannotRemoveFilewe could not remove a file.
-3005CannotMoveFilewe could not move a file.
-3006DownloadDecodingFailedMidStreamdecoding the downloaded data failed in midstream.
-3007DownloadDecodingFailedToCompletedecoding the downloaded data failed to complete.