首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

asihttp 源码分析 之4 session

2012-07-02 
asihttp 源码分析 之四 sessionsession 相关的变量// In memory caches of credentials, used on when use

asihttp 源码分析 之四 session

session 相关的变量

// In memory caches of credentials, used on when useSessionPersistence is YES
static NSMutableArray *sessionCredentialsStore = nil;
static NSMutableArray *sessionProxyCredentialsStore = nil;

// This lock mediates access to session credentials
static NSRecursiveLock *sessionCredentialsLock = nil;

// We keep track of cookies we have received here so we can remove them from the sharedHTTPCookieStorage later
static NSMutableArray *sessionCookies = nil;

?

session信息被存储的内存中。

?

开启session ,useSessionPersistence = yes。

?

- (void)readResponseHeaders方法中生产并存储session信息

?

 // Authentication succeeded, or no authentication was required if (![self authenticationNeeded]) {  // Did we get here without an authentication challenge? (which can happen when shouldPresentCredentialsBeforeChallenge is YES and basic auth was successful)  if (!requestAuthentication && [self username] && [self password] && [self useSessionPersistence]) {      NSMutableDictionary *newCredentials = [NSMutableDictionary dictionaryWithCapacity:2];   [newCredentials setObject:[self username] forKey:(NSString *)kCFHTTPAuthenticationUsername];   [newCredentials setObject:[self password] forKey:(NSString *)kCFHTTPAuthenticationPassword];      // Store the credentials in the session    NSMutableDictionary *sessionCredentials = [NSMutableDictionary dictionary];   [sessionCredentials setObject:newCredentials forKey:@"Credentials"];   [sessionCredentials setObject:[self url] forKey:@"URL"];   [sessionCredentials setObject:(NSString *)kCFHTTPAuthenticationSchemeBasic forKey:@"AuthenticationScheme"];   [[self class] storeAuthenticationCredentialsInSessionStore:sessionCredentials];  } }

?

?

?[newCredentials setObject:[self username] forKey:(NSString *)kCFHTTPAuthenticationUsername];
?? [newCredentials setObject:[self password] forKey:(NSString *)kCFHTTPAuthenticationPassword];

热点排行