Problem
The HTTPClient does not seem to be able to get the responseText/headers from the server in onerror response(the console shows everything I print in the example below as null).
Code
{noformat}
var xhr = Titanium.Network.createHTTPClient({
'timeout': 5000
});
xhr.onerror = function() {
if (this.status == 401) {
//auth challenge required
var guid = xhr.getResponseHeader('X-Challenge-GUID');
Titanium.API.info('Server gave GUID challenge of: "' + guid + '"');
Titanium.API.info('TEST FOO: ' + xhr.getResponseHeader('X-Custom-Header'));
Titanium.API.info('TEST BAR: ' + this.getResponseHeader('Cache-Control'));
Titanium.API.info('TEST BLA: ' + xhr.responseText);
Titanium.API.info('TEST BOO: ' + this.responseText);
}
}
xhr.open("GET", url);
xhr.send();
{noformat}
The getResponseHeader is responding as null. The onload method works fine but on trying to get the data from onerror "null" is returned.
Related Community Ticket
http://developer.appcelerator.com/question/50501/problem-getting-responsetextheaders-from-error-response
Not reproducible. The code missing a statement, no URL set. Website will return a 401 error and then set the url to that and then run.