File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
JSONModel/JSONModelNetworking Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,14 @@ +(NSData*)syncRequestDataFromURL:(NSURL*)url method:(NSString*)method requestBod
190
190
// turn off network indicator
191
191
if (doesControlIndicator) dispatch_async (dispatch_get_main_queue (), ^{[self setNetworkIndicatorVisible: NO ];});
192
192
193
+ // special case for http error code 401
194
+ if ([*err code ] == kCFURLErrorUserCancelledAuthentication ) {
195
+ response = [[NSHTTPURLResponse alloc ] initWithURL: url
196
+ statusCode: 401
197
+ HTTPVersion: @" HTTP/1.1"
198
+ headerFields: @{}];
199
+ }
200
+
193
201
// if not OK status set the err to a JSONModelError instance
194
202
if (response.statusCode >= 300 || response.statusCode < 200 ) {
195
203
// create a new error
@@ -301,13 +309,13 @@ +(void)JSONFromURLWithString:(NSString*)urlString method:(NSString*)method param
301
309
}
302
310
303
311
// step 3: if there's no response so far, return a basic error
304
- if (!responseData && !jsonObject ) {
312
+ if (!responseData && !error ) {
305
313
// check for false response, but no network error
306
314
error = [JSONModelError errorBadResponse ];
307
315
}
308
316
309
317
// step 4: if there's a response at this and no errors, convert to object
310
- if (error==nil && jsonObject== nil ) {
318
+ if (error==nil ) {
311
319
// Note: it is possible to have a valid response with empty response data (204 No Content).
312
320
// So only create the JSON object if there is some response data.
313
321
if (responseData.length > 0 )
You can’t perform that action at this time.
0 commit comments