mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 20:31:13 +08:00
Investigated issues surrounding inability to change HTTP AUTH credentials thoroughly. fixes #250, #237, #127
These issues has been open for some time. I have added thorough unit test coverage for scenarios of mutating the HTTP AUTH credentials on the RKClient and on individual RKRequest instances. Everything seems to work fine. Also added RKAuthenticationExample to RKCatalog for testing. Needs to be updated with support for using OAuth.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// RKNetwork.h
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 3/28/11.
|
||||
// Copyright 2011 Two Toasters
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
* Returns the global value for credential persistence to use during HTTP AUTH
|
||||
* Defaults to NSURLCredentialPersistenceForSession
|
||||
*/
|
||||
NSURLCredentialPersistence RKNetworkGetGlobalCredentialPersistence(void);
|
||||
|
||||
/**
|
||||
* Set the global value for credential persistence to use during HTTP AUTH
|
||||
*/
|
||||
void RKNetworkSetGlobalCredentialPersistence(NSURLCredentialPersistence persistence);
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// RKNetwork.m
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 3/28/11.
|
||||
// Copyright 2011 Two Toasters
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import "RKNetwork.h"
|
||||
|
||||
// Global credential persistence value.
|
||||
static NSURLCredentialPersistence gCredentialPersistence = NSURLCredentialPersistenceForSession;
|
||||
|
||||
NSURLCredentialPersistence RKNetworkGetGlobalCredentialPersistence(void) {
|
||||
return gCredentialPersistence;
|
||||
}
|
||||
|
||||
void RKNetworkSetGlobalCredentialPersistence(NSURLCredentialPersistence persistence) {
|
||||
gCredentialPersistence = persistence;
|
||||
}
|
||||
@@ -98,11 +98,11 @@
|
||||
*/
|
||||
- (NSString*)bodyAsString;
|
||||
|
||||
/*!
|
||||
/**
|
||||
* Return the response body parsed as JSON into an object
|
||||
* @deprecated in version 2.0
|
||||
*/
|
||||
- (id)bodyAsJSON;
|
||||
- (id)bodyAsJSON DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/**
|
||||
* Return the response body parsed as JSON into an object
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#import "RKResponse.h"
|
||||
#import "RKNotifications.h"
|
||||
#import "RKNetwork.h"
|
||||
#import "RKLog.h"
|
||||
#import "RKParserRegistry.h"
|
||||
#import "RKClient.h"
|
||||
@@ -151,7 +150,7 @@ extern NSString* cacheURLKey;
|
||||
NSURLCredential *newCredential;
|
||||
newCredential=[NSURLCredential credentialWithUser:[NSString stringWithFormat:@"%@", _request.username]
|
||||
password:[NSString stringWithFormat:@"%@", _request.password]
|
||||
persistence:RKNetworkGetGlobalCredentialPersistence()];
|
||||
persistence:NSURLCredentialPersistenceNone];
|
||||
[[challenge sender] useCredential:newCredential
|
||||
forAuthenticationChallenge:challenge];
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user