{ "id": "122409", "key": "TIMOB-15871", "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": [ { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-08-29T00:18:08.000+0000", "created": "2013-11-13T11:35:53.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "alloy", "android", "error", "httpclient", "module_network", "onerror", "qe-manualtest", "qe-testadded", "redirect" ], "versions": [], "issuelinks": [ { "id": "33347", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "122302", "key": "AC-2400", "fields": { "summary": "iOS: HTTPClient: autoEncodeURL not used when redirect is followed", "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" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "40376", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "135485", "key": "TIMOB-17566", "fields": { "summary": "Android: setting createHTTPClient properties autoRedirect and autoEncodeURL are ignored", "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": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-10-14T23:20:44.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "If you set httpclient.autoRedirect to false and then send a GET which returns a 302 (or anything but a 200 I'm guessing), then onerror is called instead of onload.\r\n\r\n1. 301, 302, etc. responses shouldn't be deemed an error, but if you're really set on that:\r\n2. Make it consistent. On iOS, onload is called and on Android, onerror is called. Even if you don't, at least...\r\n3. Give us all the information. Provide more than {error:'...'} to onerror. Give us the headers, the status, the responseText, responseData, etc. if they're there in the response.\r\n\r\nThis really reduces confidence in what you're doing and requires so much more testing.", "attachment": [ { "id": "50822", "filename": "workaroundApp.js", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2014-08-27T22:34:00.000+0000", "size": 1725, "mimeType": "text/javascript" } ], "flagged": false, "summary": "HTTPClient: setting autoRedirect off for 302s on Android calls onerror", "creator": { "name": "adamlynch", "key": "adamlynch", "displayName": "Adam Lynch", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "adamlynch", "key": "adamlynch", "displayName": "Adam Lynch", "active": true, "timeZone": "Europe/London" }, "environment": "Android 4.2.1 on a Samsung Galaxy S2 (Titanium 3.1.2)", "closedSprints": [ { "id": 175, "state": "closed", "name": "2014 Sprint 17 SDK", "startDate": "2014-08-21T22:07:00.000Z", "endDate": "2014-08-30T00:00:00.000Z", "completeDate": "2014-09-02T19:56:25.517Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "280481", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Hello Adam! \r\n\r\nDo you have any test case that shows this issue? \r\n\r\nTIA!\r\n\r\nBest,\r\n\r\nMauro ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-11-21T02:45:51.000+0000", "updated": "2013-11-21T02:45:51.000+0000" }, { "id": "281145", "author": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nWe have tested this issue with my test code. I got this problem. But we checked on iOS then its return success alert message. \r\n\r\nh5. Testing environment: \r\n\r\nOS: MAC OS X 10.8.5\r\n \r\nTi SDK: 3.1.3 GA \r\nTi CLI: 3.2.0\r\nAndroid SDK 4.2.2 Device \r\nAndroid SDK 4.0.3 in Emulator\r\n\r\nh5. My test code \r\n{code:javascript}\r\nvar win1 = Titanium.UI.createWindow({\r\n\t \r\n});\r\n\r\n// Create a Button.\r\nvar aButton = Ti.UI.createButton({\r\n\ttitle : 'aButton',\r\n});\r\n\r\n// Listen for click events.\r\naButton.addEventListener('click', function() {\r\n\r\n\tvar url = \"http://www.example.com/redirect.php\";\r\n\tvar client = Ti.Network.createHTTPClient({\r\n\t\t// function called when the response data is available\r\n\t\tonload : function(e) {\r\n\t\t\tTi.API.info('e ' + JSON.stringify(e));\r\n\t\t\tTi.API.info(\"Received HEADERS_RECEIVED: \" + this.HEADERS_RECEIVED);\r\n\t\t\tTi.API.info(\"Received status: \" + this.status);\r\n\t\t\tTi.API.info(\"Received statusText: \" + this.statusText);\r\n\t\t\tTi.API.info(\"Received responseText: \" + this.responseText);\r\n\r\n\t\t\talert('success');\r\n\t\t},\r\n\t\t// function called when an error occurs, including a timeout\r\n\t\tonerror : function(e) {\r\n\t\t\tTi.API.debug(e.error);\r\n\t\t\tTi.API.info(\"Received HEADERS_RECEIVED: \" + this.HEADERS_RECEIVED);\r\n\t\t\tTi.API.info(\"Received status: \" + this.status);\r\n\t\t\tTi.API.info(\"Received statusText: \" + this.statusText);\r\n\t\t\tTi.API.info(\"Received responseText: \" + this.responseText);\r\n\r\n\t\t\talert('error');\r\n\t\t},\r\n\t\ttimeout : 5000, // in milliseconds\r\n\t\tautoRedirect : false,\r\n\t\tautoEncodeUrl : false,\r\n\r\n\t});\r\n\t// Prepare the connection.\r\n\r\n\tclient.open(\"GET\", url);\r\n\t// Send the request.\r\n\tclient.send();\r\n\r\n});\r\n\r\n// Add to the parent view.\r\nwin1.add(aButton);\r\n\r\nwin1.open();\r\n{code} \r\n\r\n{code:php }\r\n\r\n{code}\r\n\r\nh5. Step to reproduces\r\n1.\tCreate a new project\r\n2.\tPaste test code in app.js\r\n3.\tNow run on android device/emulator \r\n4.\tClick on button its return error \r\n\r\n \r\n\r\nThanks\r\n", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-11-25T16:26:09.000+0000", "updated": "2013-12-04T05:49:38.000+0000" }, { "id": "306324", "author": { "name": "icaiza_", "key": "icaiza_", "displayName": "Israel", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi I have exactly the same problem, but the problem occurs when the header code is 302 or 301 which are redirecting. \r\n\r\nAnd android is only in the case of self-identification does not recover or cookie. Please any solution. \r\n\r\nregards", "updateAuthor": { "name": "icaiza_", "key": "icaiza_", "displayName": "Israel", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-05-23T21:28:26.000+0000", "updated": "2014-05-23T21:28:26.000+0000" }, { "id": "318251", "author": { "name": "nickmilner", "key": "nickmilner", "displayName": "Nick Milner", "active": true, "timeZone": "America/Los_Angeles" }, "body": "This is really a bit poor IMHO. Correctly responding to the http specification would seem to be the most basic requirement for any http implementation, especially in mobile. I just saw http://developer.appcelerator.com/question/176965/incorrect-status-returned-by-the-http-client-in-the-330-sdk and in the tests I describe there it seems Android is in a right mess. I was wondering why this is a 'low' priority ?", "updateAuthor": { "name": "nickmilner", "key": "nickmilner", "displayName": "Nick Milner", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-12T18:56:15.000+0000", "updated": "2014-08-12T18:56:15.000+0000" }, { "id": "318260", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "Yes this should be an extremely high priority. Please fix asap - this bug has hosed critical features of my app.\r\n\r\nI can confirm that the above code sample also returns a \"200\" instead of a \"301\" when pointed to the URL of \"http://google.co.nz\" using the 3.3.0 SDK. Switching back to the 3.2.3 SDK fixed the issue. \r\n\r\nI am using OS X Yosemite, with Xcode 5.1.1, iOS Simulator 7.1. Interesting that this ticket was created in a much older environment.\r\n\r\nThis ticket is a likely duplicate of TC-4562 just added.", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2014-08-12T19:46:26.000+0000", "updated": "2014-08-12T19:48:06.000+0000" }, { "id": "318261", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The description of this ticket refers to \"onerror\" being called. Is that just the side effect of the wrong response code being returned? Note that this would not explain it working in 3.2.3 and not in 3.3.0. I'm not sure TC-4562 is a duplicate.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-12T19:54:22.000+0000", "updated": "2014-08-12T19:54:22.000+0000" }, { "id": "320482", "author": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "body": "Issue can be reproduced on 3.2.3.GA and 3.3.0.GA.\r\n\r\nDue to TIMOB-17566 setting the autoRedirect in createHTTPClient() to false does not work and it defaults to true, therefore .status was always returning 200 instead of 302. This caused difficulties in being able to reproduce the issue and therefore the workaround of setting the properties via: \r\n\r\n{code}\r\nclient.setAutoRedirect(false);\r\nclient.setAutoEncodeUrl(false);\r\n{code}\r\n was used. After using the workaround I was able to reproduce the issue using the workaroundApp.js I have attached to the ticket.\r\n\r\nTested on:\r\n\r\nMac OSX 10.9.4 \r\nAppcelerator Studio, build: 3.4.0.201408270900 \r\nTitanium SDK build: 3.3.0.GA, 3.2.3.GA \r\nTitanium CLI, build: 3.3.0 \r\nAlloy: 1.3.1", "updateAuthor": { "name": "eharris", "key": "eharris", "displayName": "Ewan Harris", "active": true, "timeZone": "Europe/Dublin" }, "created": "2014-08-26T23:33:19.000+0000", "updated": "2014-08-27T22:33:27.000+0000" }, { "id": "320920", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "https://github.com/appcelerator/titanium_mobile/pull/5997", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-28T23:31:57.000+0000", "updated": "2014-08-28T23:31:57.000+0000" }, { "id": "320923", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test case:\r\n\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({\r\n\r\n});\r\n\r\n// Create a Button.\r\nvar aButton = Ti.UI.createButton({\r\n\ttitle : 'aButton',\r\n});\r\n\r\n// Listen for click events.\r\naButton.addEventListener('click', function() {\r\n\r\n\tvar url = \"http://httpbin.org/redirect/2\";\r\n\tvar client = Ti.Network.createHTTPClient({\r\n\t\t// function called when the response data is available\r\n\t\tonload : function(e) {\r\n\t\t\tTi.API.debug('########################## ONLOAD');\r\n\r\n\t\t\tTi.API.info('e ' + JSON.stringify(e));\r\n\t\t\tTi.API.info(\"Received HEADERS_RECEIVED: \" + this.HEADERS_RECEIVED);\r\n\t\t\tTi.API.info(\"Received status: \" + this.status);\r\n\t\t\talert(this.status);\r\n\t\t\tTi.API.info(\"Received statusText: \" + this.statusText);\r\n\t\t\tTi.API.info(\"Received responseText: \" + this.responseText);\r\n\r\n\t\t\talert('success');\r\n\t\t},\r\n\t\t// function called when an error occurs, including a timeout\r\n\t\tonerror : function(e) {\r\n\t\t\tTi.API.debug('########################## ERROR');\r\n\r\n\t\t\tTi.API.debug(e.error);\r\n\t\t\tTi.API.info(\"Received HEADERS_RECEIVED: \" + this.HEADERS_RECEIVED);\r\n\t\t\tTi.API.info(\"Received status: \" + this.status);\r\n\t\t\talert(this.status);\r\n\t\t\tTi.API.info(\"Received statusText: \" + this.statusText);\r\n\t\t\tTi.API.info(\"Received responseText: \" + this.responseText);\r\n\r\n\t\t\talert('error');\r\n\t\t},\r\n\t\ttimeout : 5000, // in milliseconds*\r\n\r\n\t\tautoRedirect : false,\r\n\t\tautoEncodeUrl : false,\r\n\r\n\t});\r\n\r\n\t// Prepare the connection.\r\n\tclient.setAutoRedirect(false);\r\n\tclient.setAutoEncodeUrl(false);\r\n\tclient.open(\"GET\", url);\r\n\t// Send the request.\r\n\tclient.send();\r\n\r\n});\r\n\r\n// Add to the parent view.\r\nwin1.add(aButton);\r\n\r\nwin1.open(); \r\n{code}", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-08-28T23:55:07.000+0000", "updated": "2014-08-28T23:55:07.000+0000" }, { "id": "321621", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\nOnload is called instead of onerror.\r\n\r\nClosing\r\n\r\nThe response for the test case above is:\r\n{code}\r\n[INFO] : e {\"code\":0,\"source\":{\"location\":\"http://httpbin.org/redirect/2\",\"status\":302,\"autoEncodeUrl\":false,\"timeout\":5000,\"domain\":null,\"responseText\":\"\\nRedirecting...\\n

Redirecting...

\\n

You should be redirected automatically to target URL: /redirect/1. If not click the link.\",\"autoRedirect\":false,\"connectionType\":\"GET\",\"validatesSecureCertificate\":false,\"statusText\":\"FOUND\",\"password\":null,\"allResponseHeaders\":\"Access-Control-Allow-Credentials:true\\nAccess-Control-Allow-Origin:*\\nContent-Type:text/html; charset=utf-8\\nDate:Wed, 03 Sep 2014 17:21:00 GMT\\nLocation:/redirect/1\\nServer:gunicorn/18.0\\nContent-Length:229\\nConnection:keep-alive\\n\",\"readyState\":4,\"responseXML\":null,\"responseData\":{\"file\":null,\"nativePath\":null,\"height\":0,\"length\":229,\"width\":0,\"mimeType\":\"text/html\",\"apiName\":\"Ti.Blob\",\"text\":\"\\nRedirecting...\\n

Redirecting...

\\n

You should be redirected automatically to target URL: /redirect/1. If not click the link.\",\"type\":2,\"bubbleParent\":true},\"apiName\":\"Ti.Network.HTTPClient\",\"username\":null,\"connected\":false,\"bubbleParent\":true,\"_events\":{\"disposehandle\":{}}},\"success\":true}\r\n[INFO] : Received HEADERS_RECEIVED: 2\r\n[INFO] : Received status: 302\r\n[INFO] : ALERT: (KrollRuntimeThread) [6,2604] 302\r\n[INFO] : Received statusText: FOUND\r\n[INFO] : Received responseText: \r\n[INFO] : Redirecting...\r\n[INFO] :

Redirecting...

\r\n[INFO] :

You should be redirected automatically to target URL: /redirect/1. If not click the link.\r\n[INFO] : ALERT: (KrollRuntimeThread) [4,2608] success\r\n{code}\r\n\r\nEnvironment:\r\nAppc Studio : 3.4.0.201408291834\r\nTi SDK : 3.4.0.v20140829184521\r\nMac OSX : 10.9.4\r\nAlloy : 1.5.0-dev\r\nCLI - 3.4.0-dev\r\nCode Processor: 1.1.1\r\nNexus - android 4.2.2", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-09-03T17:23:42.000+0000", "updated": "2014-09-03T17:23:42.000+0000" } ], "maxResults": 12, "total": 12, "startAt": 0 } } }