我正在做一个简单的WISPr客户端。当我使用BTOpenZone hotspot测试它时,我发现调用了willSendRequest,它会将我重定向到hotspot登录页面。我在willSendRequest中返回nil,因为我希望获得WISPr xml标记,但是我发现connectionDidFinishLoading被调用了,并且我检查没有接收到数据。
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)redirectResponse;
int statusCode = [httpResponse statusCode];
NSLog(@"redirect status code : %d", statusCode);
NSDictionary *dict = [httpResponse allHeaderFields];
NSLog(@"redirect dict : %@", [dict description]);
if (statusCode >= 300 && statusCode < 400)
{
NSLog(@"redirect requested: %@", request);
return NULL;
}
return request;
}即使我使用tcpdump来嗅探数据包,我也找不到任何WISPr标记。
你知道为什么没有WISPr xml标签吗?
我真的很感谢你们的帮助。Thx
发布于 2012-07-14 11:17:23
你不应该从返回nil
webView:resource:willSendRequest:redirectResponse:fromDataSource:
您需要的标记应该包含在该方法的NSURLResponse参数中(实际上是一个NSHTTPURLResponse),然后您应该使用登录凭据将HTTP POST请求返回到适当的URL。
https://stackoverflow.com/questions/11480368
复制相似问题