{ "id": "63481", "key": "TIMOB-2849", "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": "12079", "description": "", "name": "Sprint 2011-39", "archived": true, "released": true, "releaseDate": "2011-10-03" }, { "id": "12470", "description": "", "name": "Release 1.7.4", "archived": true, "released": true, "releaseDate": "2011-10-31" }, { "id": "11331", "description": "", "name": "Release 1.8.0", "archived": true, "released": true, "releaseDate": "2011-10-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-01-04T10:33:06.000+0000", "created": "2011-04-15T03:31:06.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "enterprise", "module_network", "qe-testadded" ], "versions": [ { "id": "11231", "name": "Release 1.5.1", "archived": true, "released": true, "releaseDate": "2011-01-24" }, { "id": "11233", "name": "Release 1.6.0", "archived": true, "released": true, "releaseDate": "2011-02-23" } ], "issuelinks": [ { "id": "17170", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "60895", "key": "TIMOB-263", "fields": { "summary": "Android: Not forwarding cookies in HTTPClient", "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-03-13T17:45:14.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": "{html}

Problem

\r\n

On Android, the \"Set-Cookie\" response header from a\r\nTi.Network.HTTPClient will only return a max of one cookie, even if\r\nmore than one cookie is set.

\r\n

For example, iPhone correctly returns the following:

\r\n
\r\nthis.getResponseHeader('Set-Cookie') == 'CookieName1=CookieValue1; path=/, CookieName2=CookieValue2; path=/';\r\n
\r\n

But Android returns the following, neglecting the second\r\nvalue:

\r\n
\r\nthis.getResponseHeader('Set-Cookie') == 'CookieName1=CookieValue1; path=/';\r\n
\r\n

Expected Behavior

\r\n

A comma delimited string of name=value; path=/ cookie strings\r\nshould be returned, just like on iPhone.

\r\n

Tested On

\r\n

Tested with Titanium Mobile SDK 1.5.1 and 1.6.0 (01/06/11).
\r\nFAILED on Android Device Samsung Epic 2.1
\r\nPASSED on iPhone Simulator

\r\n

Sample Code

\r\n

The sample code hits a public page I have created. The \"Get or\r\nSet Cookies\" button makes a request to the page, and the page will\r\neither a) echo the cookies we sent or b) if we didn't send cookies,\r\nsend us two cookies. \"Clear Cookies\" asks the server to expire the\r\ncookies.

\r\n
\r\nvar win = Titanium.UI.createWindow({ backgroundColor:'#fff' });\r\nvar testServer = 'http://appc.me/Test/Cookies/';\r\n\r\n/**\r\n * Create a text area to show responses from the server.\r\n */\r\nvar response = Titanium.UI.createTextArea({\r\n    left: 0, right: 0, top: 0, bottom: 30,\r\n    value: 'Click a button below, and the response from the server will show up here!'\r\n});\r\nwin.add(response);\r\n\r\n/**\r\n * Create a button that will hit a page on a test server that echoes any cookies we send it, or sends us two cookies.\r\n */\r\nvar getOrSetCookies = Titanium.UI.createButton({ title : 'Get or Set Cookies', left: 0, bottom: 0, width: 150, height: 30 });\r\ngetOrSetCookies.addEventListener('click', function(e) {\r\n    var xhr = Ti.Network.createHTTPClient();\r\n    xhr.onload = function(e) {\r\n        response.value = this.responseText\r\n                + '\\n\\nthis.getResponseHeader(\\'Set-Cookie\\'): '\r\n                + this.getResponseHeader('Set-Cookie');\r\n    };\r\n    xhr.open('GET', testServer + '?count=2&clear=false');\r\n    xhr.send();\r\n});\r\nwin.add(getOrSetCookies);\r\n\r\n/**\r\n * Create a button that will clear the cookies on the server (set them to expire). It will tell us how many were cleared.\r\n */\r\nvar clearCookies = Titanium.UI.createButton({ title : 'Clear Cookies', right: 0, bottom: 0, width: 150, height: 30 });\r\nclearCookies.addEventListener('click', function(e) {\r\n    var xhr = Ti.Network.createHTTPClient();\r\n    xhr.onload = function(e) {\r\n        response.value = this.responseText\r\n                + '\\n\\nthis.getResponseHeader(\\'Set-Cookie\\'): '\r\n                + this.getResponseHeader('Set-Cookie');\r\n    };\r\n    xhr.open('GET', testServer + '?count=2&clear=true');\r\n    xhr.send();\r\n});\r\nwin.add(clearCookies);\r\n\r\nwin.open();\r\n
\r\n

Log from Device

\r\n

Attached is the output from adb -d logcat. Doesn't have terribly\r\nuseful information...

\r\n

Associated Helpdesk Ticket

\r\n

http://developer.appcelerator.com/helpdesk/view/58531

{html}", "attachment": [ { "id": "18228", "filename": "cookieslogcat.rtf", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:31:07.000+0000", "size": 3297, "mimeType": "text/rtf" } ], "flagged": false, "summary": "Android: Set-Cookie Response Headers Only Returns Max of One Cookie", "creator": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "environment": "FAILED on Android Device Samsung Epic 2.1; PASSED on iPhone Simulator", "comment": { "comments": [ { "id": "129551", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

bumping the priority for next scheduling round.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:31:07.000+0000", "updated": "2011-04-15T03:31:07.000+0000" }, { "id": "158281", "author": { "name": "mvizcaino", "key": "mvizcaino", "displayName": "Miguel Vizcaino", "active": true, "timeZone": "America/Los_Angeles" }, "body": "\r\n{code:title=app.js|borderStyle=solid}\r\nvar win = Titanium.UI.createWindow({\r\n\tbackgroundColor:'white'\r\n});\r\nvar view = Ti.UI.createView({\r\n\tbackgroundColor:'blue',\r\n\ttop:10,\r\n\tbottom:10,\r\n\tright:10,\r\n\tleft:10\r\n});\r\n\r\nvar button = Titanium.UI.createButton({\r\n title: 'Click',\r\n top:230\r\n});\r\n\r\nbutton.addEventListener('click',function(e)\r\n{\r\n\tvar url = 'http://developer.appcelerator.com';\r\n\tvar xhr = Ti.Network.createHTTPClient();\r\n\txhr.onload = function(e) {\r\n\t\talert(this.getResponseHeader('Set-Cookie'));\r\n\t};\r\n\txhr.open('GET', url);\r\n\txhr.setRequestHeader('Cookie', null);\r\n\txhr.send();\r\n});\r\nview.add(button);\r\nwin.add(view);\r\nwin.open();\r\n{code} \r\n\r\n\r\nh3.Associated Helpdesk Ticket\r\nhttp://support.appcelerator.com/tickets/APP-937711\r\n\r\nh5.Customer Priority needs to be increased.", "updateAuthor": { "name": "mvizcaino", "key": "mvizcaino", "displayName": "Miguel Vizcaino", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-06-29T15:49:07.000+0000", "updated": "2011-06-30T14:37:10.000+0000" }, { "id": "159089", "author": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "h3. Associated helpdesk ticket.\r\nappc.me/c/APP-937711\r\nThis is very critical for one of the customers.", "updateAuthor": { "name": "anagesh", "key": "anagesh", "displayName": "Anirudh Nagesh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-07-08T17:46:13.000+0000", "updated": "2011-07-08T17:46:13.000+0000" }, { "id": "159518", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Bumped priority up, per email from Kincy. An enterprise client is waiting on this, and there isn't a workaround that I've been able to come up with. Can I provide more info on this, or is there anything I can do to help?", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-07-14T09:54:22.000+0000", "updated": "2011-07-14T09:54:22.000+0000" }, { "id": "159519", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "Updated sample code to point to a working server.", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-07-14T09:55:39.000+0000", "updated": "2011-07-14T09:55:39.000+0000" }, { "id": "164011", "author": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with 1.8.0.v20110819142548\nMotorola Xoom 3.2\nNexus One 2.2.2\nClear Cookies show: Set 0 cookies to expire a year ago\niPhone 4.3.4\niPad2 4.3.2\nClear Cookies show: Set 2 cookies to expire a year ago with the cookies and expire date", "updateAuthor": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-25T10:27:28.000+0000", "updated": "2011-08-25T10:27:28.000+0000" }, { "id": "164158", "author": { "name": "avaghti", "key": "avaghti", "displayName": "Alan Vaghti", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with same SDK as Natalie and got the same Android message (Clear Cookies show: Set 0 cookies to expire a year ago) with an Galaxy Tab 10.1 running 3.1.", "updateAuthor": { "name": "avaghti", "key": "avaghti", "displayName": "Alan Vaghti", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-26T11:18:37.000+0000", "updated": "2011-09-12T10:36:06.000+0000" }, { "id": "177975", "author": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening/closing to add/remove labels", "updateAuthor": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-04T10:32:46.000+0000", "updated": "2012-01-04T10:32:46.000+0000" }, { "id": "281100", "author": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Anvil test case added.\nPR link:\nhttps://github.com/appcelerator/titanium_mobile/pull/5011", "updateAuthor": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-25T08:19:02.000+0000", "updated": "2013-11-25T08:19:02.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }