http - Using AFNetworking on iOS, not getting a 302 status code in redirect -


i using afnetworking on ios , trying access webpage gives me 302 status code, redirects me , 200 when redirected page loads.

however, unable capture in ios app. tried adding authenticationchallenge block doesn't called. completionblock getting redirected view status code of 200 only. missing here? need send login details when 302 code. code pasted below:

  afhttprequestoperation *uploadoperation = [[afhttprequestoperation alloc] initwithrequest:myrequest]; [uploadoperation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id response) {     nslog(@"request: %@", [operation.request description]);     nslog(@"code: %i",operation.response.statuscode);     nslog(@"response: %@", [[nsstring alloc] initwithdata:response encoding:nsutf8stringencoding]); } failure:^(afhttprequestoperation *operation, nserror *error) {     self.statuslabel.text = @"upload failed"; }];      [uploadoperation setauthenticationchallengeblock:^(nsurlconnection *connection, nsurlauthenticationchallenge *challenge) {     nslog(@"pls authenticate"); }]; 

got it. setting wrong block. authentication challenge isn't django app sends in case of @login_required decorator. it's redirectresponse needs set!

[uploadoperation setredirectresponseblock:^nsurlrequest *(nsurlconnection *connection, nsurlrequest *request, nsurlresponse *redirectresponse) {     nslog(@"pls authenticate");     return request; }]; 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -