javascript - PhoneGap/Cordova not listening for 401, modifying http response code to 200 not working -


cpg = cordova/phonegap

this question pretty result of earlier question on phonegap/401 bug here: angular not getting response when it's non-200

the resolution (at time) implement timeout on of calls. fine until hit production. realized app being used in spotty areas, , "timeout" there wasn't enough connection @ time. so, not acceptable solution our environment/app.

since cpg not "listen" 401 response code, thought maybe change response code that's coming know cpg listens for, , modify message body , process accordingly.

so, applied @ our gateway (firewall -> loadbalancer -> gateway (where ad authentication occurs) -> service) level, process of modifying 401 responses return 200 status code, message "authentication failed", or that.

first test check , make sure response correctly via fiddler. well. next, when checking in ou cpg application (running angularjs), still never receive response. i'm able see in fiddler every time service gets called invalid credentials, returns response within 500 milliseconds. though, never receive in app.

is there header or blocking this? in fiddler, 200 response basic. read this google forums post 'www-authenticate' header cause of cpg not getting (processing) response, that's if coming in 401, not 200.

why not getting picked cpg?

here's code, not much...

$http.defaults.headers.common.authorization = 'basic ' + $rootscope.basicauth;  $http({     method: "post",     url: url,     data: {         "username": user,         "password": password,         "accesstoken": ""     },     headers: { "content-type": "application/json",     "accept-encoding": "gzip" },     timeout: 10000 }) .success(function (data, status, headers, config) {     if (data.isauthenticated) {         deferred.resolve(true);         session.setsession();     } else {         //deferred.reject(status); // 200, let's return generic message         window.logger.logit("status: " + status + "; data: " + data);         deferred.reject("authentication failed");     } }) .error(function (data, status, headers, config) {     window.logger.logit("status: " + status);     deferred.reject("authentication failed"); }); 

edit:

found bug/issue on cpg site. last comment mentions removing 'www-authenticate' header should fix issue. i've tried implementation , didn't work me either. https://issues.apache.org/jira/browse/cb-2415

you can't expect server configurable. specially when you're making app 3rd party clients. can't tell "hey, please remove www-authenticate header use app". doesn't work way.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -