{ "id": "124605", "key": "TIMOB-16154", "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": "15817", "description": "2014 Sprint 01", "name": "2014 Sprint 01", "archived": true, "released": true, "releaseDate": "2014-01-17" }, { "id": "15819", "description": "2014 Sprint 01 Core", "name": "2014 Sprint 01 Core", "archived": true, "released": true, "releaseDate": "2014-01-17" }, { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2014-01-15T01:57:53.000+0000", "created": "2014-01-09T16:35:46.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "gzip", "module_android", "qe-testadded" ], "versions": [ { "id": "15593", "description": "Release 3.1.3", "name": "Release 3.1.3", "archived": true, "released": true, "releaseDate": "2013-09-18" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [ { "id": "38330", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "131348", "key": "TIMOB-17133", "fields": { "summary": "Android: Unable to get success alert after User creation", "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": "dfortner", "key": "dfortner", "displayName": "Daniel Fortner", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2014-06-12T00:03:17.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": "h3. Issue\r\n\r\nWhen receiving Gzipped responses on Android this are being incorrectly handled as http errors by the titanium SDK even when the response code is 200 or 201.\r\n\r\nThis is only happening when the response have an empty body.\r\n\r\nh3. Logs\r\n\r\nGzip Response\r\n{code}\r\n[INFO] : Gzip Enabled\r\n[WARN] : IdleConnectionHandler: Removing a connection that never existed!\r\n[ERROR] : TiHttpClient: (TiHttpClient-23) [360048,1780592] HTTP Error (java.io.EOFException): java.io.EOFException\r\n[ERROR] : TiHttpClient: java.io.EOFException\r\n[ERROR] : TiHttpClient: \tat java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:202)\r\n[ERROR] : TiHttpClient: \tat java.util.zip.GZIPInputStream.(GZIPInputStream.java:98)\r\n[ERROR] : TiHttpClient: \tat java.util.zip.GZIPInputStream.(GZIPInputStream.java:81)\r\n[ERROR] : TiHttpClient: \tat ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:268)\r\n[ERROR] : TiHttpClient: \tat ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:217)\r\n[ERROR] : TiHttpClient: \tat org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)\r\n[ERROR] : TiHttpClient: \tat org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)\r\n[ERROR] : TiHttpClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1287)\r\n[ERROR] : TiHttpClient: \tat java.lang.Thread.run(Thread.java:841)\r\n[INFO] : XHR RESPONSE Error >>> Response:\r\n[INFO] : XHR RESPONSE Error >>> Status: 200 Type: POST Headers: Date:Thu, 09 Jan 2014 16:01:28 GMT\r\n[INFO] : Server:Apache\r\n[INFO] : Content-Encoding:gzip\r\n[INFO] : Content-Length:0\r\n[INFO] : Keep-Alive:timeout=10, max=30\r\n[INFO] : Connection:Keep-Alive\r\n[INFO] : Content-Type:image/png\r\n[DEBUG] : HTTPClient: The persistent handle is disposed.\r\n{code}\r\n\r\nNon Gzip Response\r\n{code}\r\n[INFO] : Gzip Disabled\r\n[INFO] : XHR RESPONSE Load >>> Response: \"null\"\r\n[INFO] : XHR RESPONSE Load >>> Status: 200 Type: POST Headers: Date:Thu, 09 Jan 2014 16:00:45 GMT\r\n[INFO] : Server:Apache\r\n[INFO] : Content-Length:0\r\n[INFO] : Vary:Accept-Encoding\r\n[INFO] : Keep-Alive:timeout=10, max=30\r\n[INFO] : Connection:Keep-Alive\r\n[INFO] : Content-Type:image/png; charset: UTF-8\r\n[DEBUG] : HTTPClient: The persistent handle is disposed.\r\n{code}\r\n\r\nh3. Steps to Reproduce\r\n\r\n1. Run the test case\r\n2. Click on Non Gzip Button\r\n3. Receive a load response from the xhr\r\n4. Click Gzip Button\r\n5. Receive an error response from the xhr\r\n\r\nThe php server return the same body empty response with the difference of the gzip encoding header\r\n\r\nh3. Sample Code\r\n\r\n{code}\r\n\r\nvar win = Ti.UI.createWindow();\r\nvar bt1 = Ti.UI.createButton({\r\n\ttitle:'NonGZIP',\r\n\twidth:80,\r\n\tleft:10,\r\n\tgzip:false,\r\n\tbottom:10\r\n});\r\nvar bt2 = Ti.UI.createButton({\r\n\ttitle:'GZIP',\r\n\twidth:80,\r\n\tright:10,\r\n\tgzip:true,\r\n\tbottom:10\r\n});\r\nbt1.addEventListener('click',doRequest);\r\nbt2.addEventListener('click',doRequest);\r\n\r\nwin.add(bt1);\r\nwin.add(bt2);\r\nwin.open();\r\nfunction doRequest(e){\r\n\tvar xhr = Ti.Network.createHTTPClient(); \r\n\t\r\n\txhr.onload = function(e){\r\n\t Titanium.API.info('XHR RESPONSE Load >>> Response: \"'+this.responseText+'\"');\r\n\t Titanium.API.info('XHR RESPONSE Load >>> Status: '+this.status+' Type: '+ this.connectionType+' Headers: '+ this.allResponseHeaders);\r\n\t};\r\n\t\r\n\txhr.onerror = function(e){\r\n\t Titanium.API.info('XHR RESPONSE Error >>> Response: '+this.responseText);\r\n\t Titanium.API.info('XHR RESPONSE Error >>> Status: '+this.status+' Type: '+ this.connectionType+' Headers: '+ this.allResponseHeaders);\r\n\t};\r\n\t\r\n\ttry {\t\r\n\t\txhr.open('POST','http://demo.cotaman.com/gzip.php');\r\n\t\txhr.setRequestHeader('User-Agent', Ti.userAgent);\r\n\t\txhr.setRequestHeader('x-cmk-agent', 'M3 v' + Ti.App.version);\r\n\t\tif(e.source.gzip){\r\n\t\t\txhr.setRequestHeader('Accept-Encoding', 'gzip,deflate');\r\n\t\t\tTi.API.info('Gzip Enabled');\r\n\t\t}else{\r\n\t\t\tTi.API.info('Gzip Disabled');\r\n\t\t}\r\n\t\tvar imageFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,'image.jpg');\r\n if(imageFile.exists()) {\r\n \txhr.send({\r\n\t media: imageFile.read(),\r\n\t test: 'pic_'\r\n \t});\r\n }\r\n\t} catch(e) {\r\n\t currentAction = null;\r\n\t Ti.API.info('ERROR : '+e.message);\r\n\t}\r\n};\r\n\r\n\r\n{code}\r\n\r\nSample App at https://www.dropbox.com/s/dhd9czzl5u488ft/testcase.zip", "attachment": [], "flagged": false, "summary": "Android: XHR GZip 200 response code handled as error", "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": "Product: Titanium SDK\r\nTitanium SDK: Mobile 3.1GA\r\nPlatform OS: Android\r\nPlatform OS Version: Windows 7/OSX", "comment": { "comments": [ { "id": "288049", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test case to verify that GZIP works:\n\n{code}\nTi.UI.backgroundColor = '#dddddd';\n \nvar url = \"https://raw.github.com/appcelerator/titanium_mobile/master/package.json\";\nvar win = Ti.UI.createWindow();\n \nvar xhr = Ti.Network.createHTTPClient({\n onload: function() {\n Ti.API.debug(this.responseText);\n \n },\n onerror: function(e) {\n Ti.API.debug(\"STATUS: \" + this.status);\n Ti.API.debug(\"TEXT: \" + this.responseText);\n Ti.API.debug(\"ERROR: \" + e.error);\n alert('There was an error retrieving the remote data. Try again.');\n },\n timeout:5000\n});\n \n \nxhr.open(\"GET\", url);\nxhr.setRequestHeader(\"Accept-Encoding\",\"gzip,deflate\"); \nxhr.send();\n \nwin.open();\n{code}", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-14T01:05:59.000+0000", "updated": "2014-01-14T01:05:59.000+0000" }, { "id": "288050", "author": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Master PR: https://github.com/appcelerator/titanium_mobile/pull/5214\n\nPlease test both original, and second test case to verify that gzip still works.", "updateAuthor": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-01-14T01:25:37.000+0000", "updated": "2014-01-14T01:25:37.000+0000" }, { "id": "303591", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix. We see XHR GZip 200 response as expected in the console & do not see any errors.\r\n\r\nEnvironment:\r\nAppc Studio : 3.2.3.201404181520\r\nTi SDK : 3.3.0.v20140502133323\r\nMac OSX : 10.8.5\r\nAlloy : 1.3.1\t\r\nCLI - 3.2.3\r\nNexus 5 - android 4.4.2", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-05-06T00:56:03.000+0000", "updated": "2014-05-06T00:56:03.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }