Inappropriate NSError from -[NSURLConnection sendSynchronousRequest:::]
Inappropriate NSError from -[NSURLConnection sendSynchronousRequest:::]
- Subject: Inappropriate NSError from -[NSURLConnection sendSynchronousRequest:::]
- From: Jerry Krinock <email@hidden>
- Date: Sun, 4 Oct 2009 22:01:47 -0700
In Mac OS 10.5, if I construct an NSURL containing a username and
password embedded in the URL, and if that username and password is
bad, i.e.
https://BadUsername:email@hidden/v1/posts/update#
and then I feed this NSURL in a NSURLRequest to
-[NSURLConnection sendSynchronousRequest:returningResponse:error:]
it returns an NSError in domain NSURLErrorDomain with errorCode
NSURLErrorUserCancelledAuthentication = -1012.
This seems to be fishy because the user didn't cancel -- the user
provided a bad username/password.
I would like to detect the given NSError and map it to appropriate
alert text. So, following the First Theorem of Reverse Engineering, I
am going to set aside common sense, and map
NSURLErrorUserCancelledAuthentication to tell the user that "The
username/password you entered was not accepted by the server."
Since there is no documentation on exactly what NSError is provided,
I'm worried that Apple is going to fix this someday by defining and
returning a more proper error code, NSURLErrorBadCredential or
something like that, and this will break my app.
Could someone please explain the logic of how "bad username/password"
became "user cancelled", and how permanent is this association?
By the way, NSURLErrorUserCancelledAuthentication is, in my opinion,
the 2nd-most appropriate error code for bad username/password which is
currently defined in NSURLErrorDomain.
NSURLErrorUserAuthenticationRequired = -1013 might be a little more
appropriate, but still that implies a *missing* instead of a *wrong*
credential.
Sincerely,
Jerry Krinock
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden