我正在尝试使用 NSMutableURLRequest 与会话建立连接。我正在开始从它接收数据的第一个请求。但我不能提出第二个要求。如何使用相同的 cookie 发出第二个请求?
更新源代码:
NSHTTPURLResponse * response;
NSError * error;
NSMutableURLRequest * request;
request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://loginsite"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60];
NSString *post = [NSString stringWithFormat:@"userid=%@&pass=%@",self.userName.text, self.password.text];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setValue:[NSString stringWithFormat:@"%d", [postData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
self.urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[self.urlConnection start];
它提出了第一个请求,但我怎样才能提出第二个请求?