在用户输入正确的登录名和密码后,我需要检测 HTTP 代码 302,我正在使用这种方法:
- (void) connection:(NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"connection:didReceiveResponse");
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
int status = [httpResponse statusCode];
if (status == 302) {
//do something here
}
else
{
NSLog(@"http status code: %d", status);
}
[connection cancel];
}
}
但是我只能在页面重定向后获得状态码 200,请问有什么想法吗?
谢谢!