Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9558] iOS: XHR calls fail if the response data has invalid encoding

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-06-26T10:11:19.000+0000
Affected Version/sRelease 2.1.0, Release 2.0.1
Fix Version/sSprint 2012-13 API, Release 2.1.1, Release 3.0.0
ComponentsiOS
Labelsapi, module_xml, qe-testadded
ReporterFederico Casali
AssigneeVishal Duggal
Created2012-06-14T16:24:07.000+0000
Updated2013-12-10T06:02:38.000+0000

Description

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();

Comments

  1. Vishal Duggal 2012-07-12

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2546 against 2_1_X
  2. Satyam Sekhri 2012-07-16

    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
  3. Shameer Jan 2013-12-10

    Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5039

JSON Source