ios - What is the recommended way to intercept and prevent redirects with AFNetworking 2.0? -


it seems me proper place in afurlsessionmanager, in setting taskwillperformhttpredirection block, unsure of best way handle it.

currently, in afhttpsessionmanager subclass, setting redirect block globally requests, , know can prevent redirects returning nil here:

- (void)setupredirectblock {     [self settaskwillperformhttpredirectionblock:^nsurlrequest *(nsurlsession *session, nsurlsessiontask *task, nsurlresponse *response, nsurlrequest *request) {         return nil;     }]; } 

...but need on specific tasks, , there doesn't appear way information task itself.

i guess looking sort of user info dictionary or can use set flag telling method either return request or return nil. currently, looks have string comparison on response/request url in client far away task , path created.

so begs question, fighting convention, or there no better way intercept afnetworking 2.0 redirect on task-by-task basis?

settaskwillperformhttpredirectionblock best way intercept redirects. session manager responsible determining when or when not prevent redirects based on request associated task. in cases, path of request should sufficient determination, user additionally tag information in custom request header field.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -