{ "id": "121281", "key": "TIMOB-15505", "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-10-16T18:29:07.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "reprod", "supportTeam" ], "versions": [ { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "15479", "description": "Release 3.1.2", "name": "Release 3.1.2", "archived": true, "released": true, "releaseDate": "2013-07-31" }, { "id": "15593", "description": "Release 3.1.3", "name": "Release 3.1.3", "archived": true, "released": true, "releaseDate": "2013-09-18" }, { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:14.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": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "h3. PROBLEM\r\n\r\nWhen using an httpClient connection and this is succesful the event return a response code of 0, when user tries to do a validation of the response code they get a false as they expect a 200 response.\r\n\r\n \r\nh3. EVENT OUTPUT\r\n\r\n{code}\r\n[INFO] : {\r\n[INFO] : code = 0;\r\n[INFO] : source = \"[object TiNetworkClient]\";\r\n[INFO] : success = 1;\r\n[INFO] : type = load;\r\n[INFO] : }\r\n{code}\r\n\r\n\r\nh3. TEST CASE\r\n\r\n{code}\r\n\r\nvar w = Ti.UI.createWindow();\r\n\r\nvar url = \"http://www.cotaman.com/return.php?id=200\"; \r\n var client = Ti.Network.createHTTPClient({ \r\n // function called when the response data is available \r\n onload : function(e) { \r\n \tconsole.log('success>>>'); \r\n console.log(e); \r\n }, \r\n // function called when an error occurs, including a timeout \r\n onerror : function(e) { \r\n console.log(\"error>>>\");\r\n console.log(e);\r\n }, \r\n timeout : 5000 // in milliseconds \r\n }); \r\n // Prepare the connection. \r\n client.open(\"GET\", url); \r\n // Send the request. \r\n client.send(); \r\n\r\nw.open();\r\n{code}\r\n\r\nh3. CONSOLE LOG\r\n\r\n{code}\r\n[INFO] : APP-739978/1.0 (3.1.3.GA.222f4d1)\r\n[INFO] : success>>>\r\n[INFO] : {\r\n[INFO] : code = 0;\r\n[INFO] : source = \"[object TiNetworkClient]\";\r\n[INFO] : success = 1;\r\n[INFO] : type = load;\r\n[INFO] : }\r\n{code}\r\n\r\nh3. SDK CODE\r\n\r\nAs doing a review we found that a 0 response is hard coded in the Titanium SDK on TiNetworkHTTPClientProxy.m\r\n\r\n{code}\r\nif (hasOnerror && (responseCode >= 400) && (responseCode <= 599))\r\n\t\t{\r\n\t\t\tNSMutableDictionary * event = [TiUtils dictionaryWithCode:responseCode message:@\"HTTP error\"];\r\n\t\t\t[event setObject:@\"error\" forKey:@\"type\"];\r\n\t\t\t[self fireCallback:@\"onerror\" withArg:event withSource:thisPointer];\r\n\t\t}\r\n\t\telse if(hasOnload)\r\n\t\t{\r\n\t\t\tNSMutableDictionary * event = [TiUtils dictionaryWithCode:0 message:nil];\r\n\t\t\t[event setObject:@\"load\" forKey:@\"type\"];\r\n\t\t\t[self fireCallback:@\"onload\" withArg:event withSource:thisPointer];\r\n\t\t}\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: HttpClient onload event returns responseCode of 0", "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": "Titanium SDK: Mobile 3.1GA, 3.2.1.GA,\r\nTi CLI 3.2.1\r\nPlatform OS: iOS\r\nPlatform OS Version: 7", "comment": { "comments": [ { "id": "422523", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "I am able to reproduce this issue with the following environment;\r\niPhone 7 (10.2)\r\nStudio 4.9.0.201705302345\r\nTi SDK 6.1.1.v20170620103414\r\nAppc NPM 4.2.9\r\nAppc CLI 6.2.1\r\nTi CLI 5.0.13\r\nAlloy 1.9.11\r\nArrow 2.0.0\r\nXcode 8.2 (8C38)\r\nNode v4.8.2\r\nJava 1.8.0_131", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-06-21T23:05:57.000+0000", "updated": "2017-06-21T23:05:57.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }