{ "id": "136134", "key": "TIMOB-17625", "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": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-09-05T21:27:00.000+0000", "created": "2014-09-05T00:07:38.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "supportTeam" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" }, { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "issuelinks": [ { "id": "40879", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "133374", "key": "TIMOB-17432", "fields": { "summary": "iOS: HTTPClient not fire onload onerror when set option async false", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-21T20:59:04.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h3. Issue\r\n\r\nWhen setting the async parameter as false in the HttpClient the callbacks unload and on error are not being called in Ti SDK3.3.0 and 3.4.0, the same code in SDK 3.2.3.GA the callback are correctly executed.\r\n\r\nh3. Test code\r\n\r\nTest case attached (network.js)\r\n\r\nh5. app.js\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor:'white'\r\n});\r\n\r\nvar xhr = require('commonjs/xhr');\r\nvar url = \"http://roi-stg.mcd.com/mobile/localization/au/v3.1/iPhone/image_resources.zip\";\r\nvar sync = true;\r\n\r\nfunction doCall(_url,_method,_sync){\r\n\t\txhr.doCALL(_method,_url,{},callback,_sync);\r\n}\r\n\r\nfunction callback(_args) {\r\n\talert(\"HTTPClient \" + _args);\r\n Ti.API.info(\"HTTPClient \" + _args);\r\n}\r\n\r\nvar view = Ti.UI.createView({\r\n\ttop:75,\r\n\tlayout:'vertical'\r\n});\r\n\r\nvar bt_HEAD = Ti.UI.createButton({\r\n\ttitle: \"XHR HEAD\"\r\n});\r\nvar view2 = Ti.UI.createView({\r\n\tlayout:'horizontal'\r\n});\r\nvar label = Ti.UI.createLabel({\r\n\ttext:'SYNC',\r\n\twidth:Ti.UI.SIZE\r\n});\r\nvar basicSwitch = Ti.UI.createSwitch({\r\n value:true // mandatory property for iOS \r\n});\r\nview2.add(label);\r\nview2.add(basicSwitch);\r\n\r\nbasicSwitch.addEventListener('change',function(e){\r\n Ti.API.info('Switch value: ' + basicSwitch.value);\r\n sync = basicSwitch.value;\r\n});\r\n\r\nbt_HEAD.addEventListener('click',function(e){\r\n\tdoCall(url,'HEAD',sync);\r\n});\r\n\r\nview.add(bt_HEAD);\r\nview.add(view2);\r\nwin.add(view);\r\nwin.open();\r\n{code}\r\n\r\nh5. xhr.js\r\n{code}\r\nexports.doCALL = function (_method,_url, _params, _callback,_sync){\r\n\t// XHR POST\r\n\tvar xhr = Titanium.Network.createHTTPClient();\r\n\txhr.onload = function(e)\r\n\t{\r\n\t _callback(this.responseText);\r\n\t};\r\n\txhr.onerror = function(e)\r\n\t{\r\n\t _callback('XHR >>> '+JSON.stringify(e));\r\n\t};\r\n\txhr.open(_method, _url, _sync);\r\n\txhr.send();\r\n};\r\n{code}\r\n\r\nh3. Steps to repro\r\n\r\n1. Run test case\r\n2. Use the Sync switch and set to false \r\n3. Press XHR HEAD\r\n\r\nExpected Result:\r\nAn alert showing the result of the httpClient call.\r\n\r\nActual Result:\r\nNo alert is shown as the callbacks are not called.", "attachment": [ { "id": "50996", "filename": "network.zip", "author": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-09-05T00:07:38.000+0000", "size": 2455721, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: HttpClient with async as false not responding", "creator": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Ti SDK: 3.3.0 & 3.4.0\r\nSystem: iOS ", "comment": { "comments": [ { "id": "322028", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Is this not a duplicate of TIMOB-17432?", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-05T13:54:17.000+0000", "updated": "2014-09-05T13:54:17.000+0000" }, { "id": "322082", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "If you're making a SYNC call, there are no callbacks, the code will wait for the \"send\" call to be done. Try this:\r\n{code}\r\nexports.doCALL = function (_method,_url, _params, _callback,_sync){\r\n\t// XHR POST\r\n\tvar xhr = Titanium.Network.createHTTPClient();\r\n\txhr.onload = function(e)\r\n\t{\r\n\t _callback(this.responseText);\r\n\t};\r\n\txhr.onerror = function(e)\r\n\t{\r\n\t _callback('XHR >>> '+JSON.stringify(e));\r\n\t};\r\n\txhr.open(_method, _url, _sync);\r\n\txhr.send();\r\n\t// If it's a sync call, you can grab the response text after\r\n\tif(_sync == false) {\r\n\t\t_callback(xhr.responseText);\r\n\t}\r\n};\r\n{code}", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-09-05T17:55:19.000+0000", "updated": "2014-09-05T18:01:21.000+0000" }, { "id": "322083", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Documentation: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Network.HTTPClient-method-send", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-09-05T17:59:30.000+0000", "updated": "2014-09-05T17:59:30.000+0000" }, { "id": "322139", "author": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Marking this as invalid since making asynchronous calls on the HTTP Client does not fire the callback, this is by design. The sample in my previous comments should solve the issue.", "updateAuthor": { "name": "penrique", "key": "penrique", "displayName": "Pedro Enrique", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-09-05T21:27:00.000+0000", "updated": "2014-09-05T21:27:00.000+0000" }, { "id": "322302", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is a behavior change. In ASIHttp, we specifically hacked around the behavior to make a callback on a synchronous call. In NSURLConnection, we decided this was no longer a good idea and stopped it. In general, we strongly recommend you not use synchronous network calls unless there is a good rationale of doing so.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-08T17:15:34.000+0000", "updated": "2014-09-08T17:15:34.000+0000" }, { "id": "414400", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T20:59:04.000+0000", "updated": "2017-03-21T20:59:04.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }