{ "id": "170801", "key": "TIMOB-25686", "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": "2018-01-16T13:38:48.000+0000", "priority": null, "labels": [ "andoid", "engSchedule", "httpclient", "ios", "spec" ], "versions": [ { "id": "17609", "description": "", "name": "Release 7.0.0", "archived": false, "released": true, "releaseDate": "2017-12-07" }, { "id": "20791", "name": "Release 8.0.2", "archived": false, "released": true, "releaseDate": "2019-06-18" } ], "issuelinks": [], "assignee": null, "updated": "2019-07-30T15:38:49.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": "{code:javascript}\r\nfunction getXhr() {\r\n if (typeof Ti !== 'undefined') {\r\n return Ti.Network.createHTTPClient();\r\n }\r\n if (typeof XMLHttpRequest) {\r\n return new XMLHttpRequest();\r\n }\r\n throw Error('Unknown environment');\r\n}\r\nvar xhr = getXhr();\r\nxhr.onload = function () {console.log('onload' + ' ' + xhr.status)};\r\nxhr.onerror = function () {console.log('onerror' + ' ' + xhr.status)};\r\nxhr.addEventListener('load', function() {console.log('load' + ' ' + xhr.status)});\r\nxhr.addEventListener('error', function() {console.log('error' + ' ' + xhr.status)});\r\n\r\nxhr.open('GET', 'http://www.httpbin.org/status/400'); //returns 400 status\r\nxhr.send();\r\n{code}\r\n\r\nConsole output in browser:\r\n{noformat}\r\nonload 400\r\nload 400\r\n{noformat}\r\n\r\nOutput in Titanium:\r\n{noformat}onerror{noformat}\r\n", "attachment": [], "flagged": false, "summary": "HTTPClient compliance with XMLHttpRequest specifications", "creator": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "subtasks": [], "reporter": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "environment": "SDK 7+, iOS, Android, probably Windows too (TIMOB-19042)", "comment": { "comments": [ { "id": "433186", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~s.volkov], can you add a bit more context here? 400-500 error codes usually return in the {{onerror}} callback. The {{load}} and {{error}} *events* should not even exist. But I am open for improvements here, although it would mean a quite huge breaking change for advanced use-cases.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-01-16T14:19:32.000+0000", "updated": "2018-01-16T14:19:32.000+0000" }, { "id": "433187", "author": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "body": "I'm not insisting on events implementation (nevertheless, it would be nice to have fullspec compilant xhr).\r\n\r\nProblem is that XMLHttpRequest does not call onerror callback on status >=400, but Titanium does. You can try example above in any browser (of course in \"www.httpbin.org\" origin).\r\n", "updateAuthor": { "name": "s.volkov", "key": "s.volkov", "displayName": "Sergey Volkov", "active": true, "timeZone": "Europe/Moscow" }, "created": "2018-01-16T14:41:44.000+0000", "updated": "2018-01-16T14:41:44.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }