私は次のコードを使用します:
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSHTTPURLResponse *)response {
NSLog(@"Received redirect Response: %@ %@", [response allHeaderFields], [NSHTTPURLResponse localizedStringForStatusCode:[response statusCode]]);
return request;
}
次のヘッダーデータを含む302を受け取ったとき:
< HTTP/1.1 302 Found
< Date: Wed, 03 Mar 2010 07:47:17 GMT
< Server: lighttpd/1.4.19
< Content-length: 0
< Content-type: text/html;charset=utf-8
< Location: `<new Location>`
< Vary: Accept-Encoding
これはgdbコンソールの出力です:
2010-03-03 08:42:03.265 MyProg [68106:207]受信したリダイレクト応答:(null)サーバーエラー2010-03-03 08:42:14.414 MyProg [68106:207]受信したリダイレクト応答:{
Connection = "Keep -生きている";
"Content-Encoding" = gzip;
"Content-Length" = 20;
"Content-Type" = "text / html; charset = utf-8";
日付="2010年3月3日水曜日07:42:10GMT";
"Keep-Alive" = "timeout = 15、max = 100";
場所="<new Location>
";
サーバー="lighttpd/ 1.4.19";
Vary = "Accept-Encoding"; } 見つかった
Curlを使用すると、応答が1つだけ返され、tracedumpが同じことを通知するため、サーバーがリダイレクトを1つだけ送信すると確信しています。
このセレクターが2回呼び出されるのはなぜですか?