I haven't been able to find any documentation or relevant Web results regarding 
a situation I'm experiencing:

I get different results for the same identical NSURLRequest when I execute the 
request using NSURLConnection's +sendSynchronousRequest versus when I execute 
using asynchronously by allocating an NSURLConnection's instance and calling 
-start on it.

The particular request results in an HTTP 401 response (Not Authorized).

When I execute asynchronously:
        1a) -connection:didReceiveResponse: is invoked and supplies an 
NSHTTPURLResponse object
        1b) the NSHTTPURLResponse object reports the HTTP result of 401 vis 
-statusCode.
        2) -connection:didReceiveData: does receive data
        3) -connection:didFailWithError is NOT invoked.

When I execute synchronously with 
-sendSynchronousRequest:returningResponse:error:
        1) the method does return the same data as the async
        2) but: no response is returned
        3) and: an NSError is returned, with the code of -1012 (which is 
NSURLErrorUserCancelledAuthentication as defined in NSURL.h)

I expected the sendSynchronousRequest approach to return an NSHTTPURLResponse 
object without an error because, according to the docs, the synchronous method 
is built on top of the asynchronous methods. The asymmetry of the response is a 
unsettling as I'm trying to have my code work either with synchronous or 
asynchronous, but having to interpret results differently is making this a 
nuisance (especially mapping NSURL error codes back to HTTP status codes). 

Do I have unreasonable expectations? incorrect understanding? or should I be 
getting similar/identical results, and so look for a bug?

Thanks for any advise...

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to