Problem description
XHR calls fail if the response data has invalid encoding
Steps to reproduce and sample code
Run the sample code using the url provided in the bug comments below
Result: responseText it's null
This behavior it's only reproducible with the provided url page.
The page it's recognized from the browser as encoded with Western (ISO-8859-1). Encoding it with Unicode (UTF-8) would solve the issue and response text it's returned as expected.
var win = Titanium.UI.createWindow({
title:'test',
backgroundColor:'white'
});
var xhr = Titanium.Network.createHTTPClient({
enableKeepAlive: true,
});
xhr.onerror = function(e) {
Ti.API.error('#### Error received while requesting intraday data: ' + JSON.stringify(e));
};
xhr.onreadystatechange = function(e) {
Ti.API.info("#### " + this.readyState);
};
xhr.onload = function(e) {
if(this.status == 200) {
Ti.API.info('#### response text: ' + this.responseText);
}
};
xhr.open('GET', "SEE COMMENT FOR URLs");
xhr.send();
win.open();
Pull pending https://github.com/appcelerator/titanium_mobile/pull/2546 against 2_1_X
Response data shown for the XHR call. Verified on: Titanium Studio: 2.1.1.201207161421 Titanium SDK: 2.1.1.v2012071618060 iOS: iPhone simulator 5.0
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5039