Sto tentando di eseguire una richiesta su un server, che risponde con un Etag ai fini della cache. Ho scritto il seguente codice per questo, ma la risposta per queste chiamate è casuale la maggior parte del tempo, ad esempio il codice di stato a volte di risposta è 200 e alcune volte 304 (previsto). Sto facendo qualcosa di sbagliato nel mio codice o c'è qualcosa di specifico con AFNetworking che dovrei tenere a mente.!AFNetworking - Richieste con ETag
NSURL *url = [NSURL URLWithString:@"http://ia.media-imdb.com/images/M/[email protected]@._V1._SY90_.jpg"];
NSMutableURLRequest *aRequest = [NSMutableURLRequest requestWithURL:url];
[aRequest setValue:@"\"61-smtLpBSL_SY90_#1\"" forHTTPHeaderField:@"If-None-Match"];
NSLog(@"headers: %@", aRequest.allHTTPHeaderFields);
AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:aRequest imageProcessingBlock:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSLog(@"%@ %d", response.allHeaderFields, response.statusCode);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
NSLog(@"Request failed with error: %@", error);
}];
[operation start];
Sei mai arrivato in fondo a questo? – andygeers