{ "id": "113375", "key": "TIMOB-13930", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2013-04-25T08:13:44.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "parity" ], "versions": [ { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:29.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [], "description": "*Problem description*\r\nOn Android, setting the property autoRedirect to false causes onerror to be called instead of onload. It works as expected on iOS.\r\n\r\n*Actual result*\r\nHttpClient is calling onerror instead of onload\r\n\r\n*Expected result*\r\nonload should be called on Android even if it is a HTTP redirect (302 or 304), since these are not errors.\r\n\r\n*Test case*\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"#FFF\"\r\n});\r\n\r\nvar onload = function(e) {\r\n\talert(this.test_type + \": RETURN CODE:\" + this.status);\r\n};\r\nvar onerror = function(e) {\r\n\talert(this.test_type + \": ERROR CODE:\" + this.status);\r\n};\r\nvar xhr = Ti.Network.createHTTPClient({\r\n\tonload : onload,\r\n\tonerror : onerror,\r\n\ttest_type : \"DEFAULT\"\r\n});\r\nxhr.open('GET', 'https://support.appcelerator.com');\r\nxhr.send();\r\n\r\nvar xhr1 = Ti.Network.createHTTPClient({\r\n\tonload : onload,\r\n\tonerror : onerror,\r\n\ttest_type : \"REDIRECT OFF\"\r\n});\r\nxhr1.open('GET', 'https://support.appcelerator.com');\r\nxhr1.autoRedirect = false;\r\nxhr1.send();\r\n\r\nvar xhr2 = Ti.Network.createHTTPClient({\r\n\tonload : onload,\r\n\tonerror : onerror,\r\n\ttest_type : \"REDIRECT ON\"\r\n});\r\nxhr2.open('GET', 'https://support.appcelerator.com');\r\nxhr2.autoRedirect = true;\r\nxhr2.send();\r\n\r\nwin.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: HttpClient calls onerror instead of onload if autoRedirect is set to false", "creator": { "name": "nasif", "key": "nasif", "displayName": "Nasif", "active": true, "timeZone": "Asia/Kolkata" }, "subtasks": [], "reporter": { "name": "nasif", "key": "nasif", "displayName": "Nasif", "active": true, "timeZone": "Asia/Kolkata" }, "environment": "Titanium Studio 3.1.0", "comment": { "comments": [ { "id": "249248", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello!\n\nIn order to promote this bug into Mobile SDK, can you please provide more info? Please follow this guideline: \n\nhttps://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report\n\nIf you have a small testcase showing this, will be awesome!\n\nBest,\nMauro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-04-26T23:43:36.000+0000", "updated": "2013-04-26T23:43:36.000+0000" }, { "id": "249269", "author": { "name": "nasif", "key": "nasif", "displayName": "Nasif", "active": true, "timeZone": "Asia/Kolkata" }, "body": "var onload = function(e) {\n Ti.API.info(this.test_type + \": RETURN CODE:\" + this.status);\n};\nvar onerror = function(e) {\n Ti.API.info(this.test_type + \": ERROR CODE:\" + this.status);\n};\nvar xhr = Ti.Network.createHTTPClient({\n onload: onload,\n onerror: onerror,\n test_type: \"DEFAULT\"\n});\nxhr.open('GET','https://support.appcelerator.com');\nxhr.send();\n\nvar xhr1 = Ti.Network.createHTTPClient({\n onload: onload,\n onerror: onerror,\n test_type: \"REDIRECT OFF\"\n});\nxhr1.open('GET','https://support.appcelerator.com');\nxhr1.autoRedirect = false;\nxhr1.send();\n\nvar xhr2 = Ti.Network.createHTTPClient({\n onload: onload,\n onerror: onerror,\n test_type: \"REDIRECT ON\"\n});\nxhr2.open('GET','https://support.appcelerator.com');\nxhr2.autoRedirect = true;\nxhr2.send();\n\n", "updateAuthor": { "name": "nasif", "key": "nasif", "displayName": "Nasif", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-04-27T10:57:16.000+0000", "updated": "2013-04-27T10:57:16.000+0000" }, { "id": "252977", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested and confirmed on Android 4.1.2 x86 emulator with Ti SDK 3.2 CI. Works as expected on iOS.", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-20T23:08:19.000+0000", "updated": "2013-05-20T23:08:19.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }