{ "id": "118117", "key": "TIMOB-14782", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "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": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2018-01-25T18:23:48.000+0000", "created": "2013-08-07T22:50:00.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "supportTeam" ], "versions": [ { "id": "15478", "description": "Release 3.1.1", "name": "Release 3.1.1", "archived": true, "released": true, "releaseDate": "2013-06-17" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" }, { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-01-25T18:23:52.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": [], "description": "On the iOS platform, a developer can not set the Accept-Encoding header as one would expect. It is always defaulting to Accept-Encoding=gzip.\r\n\r\nWe are forcing the Accept-Encoding=gzip on our side because of this line:\r\n\r\n[request setAllowCompressedResponse:YES]; (TiNetworkHTTPClientProxy.m line 596)\r\n\r\nBasically, the ASIHTTPRequest that we are using defaults to overriding the Accept-Encoding to gzip if this flag above is YES (which is the default). In our TiNetworkHttpClientProxy, we are also specifically setting this flag to YES in the send function without checking to see if the user has overridden the Accept-Encoding header. So in this case that means that we can not override the Accept-Encoding header at all, and it will always default to gzip value.\r\n\r\nThe fix i propose is pretty easy – we just need to allow the user to set an allowCompressedResponse property on the request object, and then check to see what it is when we are going through the send function and set it accordingly.\r\n\r\nHere is my replacement code:\r\n\r\n if([TiUtils boolValue:[self valueForUndefinedKey:@\"cache\"] def:YES]){\r\n [request setAllowCompressedResponse:YES];\r\n }\r\n else{\r\n [request setAllowCompressedResponse:NO];\r\n }\r\n\r\nThis is pretty quick and dirty and end the end, you would need to set this flag to false on the XHR in order to allow the Accept-Encoding header to be set, so there may certainly be a more elegant way for this to work.", "attachment": [], "flagged": false, "summary": "iOS: Unable to set Accept-Encoding header on Ti.Network.HTTPClient ", "creator": { "name": "bgrantges@appcelerator.com", "key": "bgrantges", "displayName": "Bert Grantges", "active": false, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "bgrantges@appcelerator.com", "key": "bgrantges", "displayName": "Bert Grantges", "active": false, "timeZone": "America/Chicago" }, "environment": "iOS", "closedSprints": [ { "id": 990, "state": "closed", "name": "2018 Sprint 02 SDK", "startDate": "2018-01-14T22:48:43.544Z", "endDate": "2018-01-28T22:48:00.000Z", "completeDate": "2018-01-29T16:22:42.911Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "265513", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "As per RFC 2616, section 14.3 ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 ), we are claiming we can take identity (uncompressed) as well as gzip. This is perfectly valid.\n\nThis is not a bug, but instead a feature to override West_Interactive's server fault. Their server response was to claim Content-Encoding: gzip for an uncompressed JSON.\n\nMoving to mark this a new feature, but I'm not sure of why we would intentionally disable gzip compression except to compensate for buggy servers.", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-08T00:34:22.000+0000", "updated": "2013-08-08T00:34:22.000+0000" }, { "id": "297713", "author": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "body": "[~ingo] it is possible to allow user to set the Accept-Encoding from something different than just \"gzip\", currently when they try to set it to \"gzip, deflate\" and due the inability to do it they have been forced to run their calls through a proxy.\n\n{code}\nvar client = Ti.Network.createHTTPClient({\n // function called when the response data is available\n onload : function(e) {\n // Do Something\n },\n // function called when an error occurs, including a timeout\n onerror : function(e) {\n // Do Something\n },\n timeout : 5000 // in milliseconds\n});\n\n// Prepare the connection.\nclient.open(\"GET\", url);\n\n// Modify client as needed - IT'S THIS PROPERTY THAT DOESN'T PERSIST\nclient.setRequestHeader('Accept-Encoding', 'gzip,deflate');\n\n// Send the request.\nclient.send();\n{code}", "updateAuthor": { "name": "mcota", "key": "mcota", "displayName": "Marco Cota", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-03-18T15:39:17.000+0000", "updated": "2014-03-18T15:39:17.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }