[TIMOB-2698] Support for "Accept-Encoding","gzip,deflate"
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2011-11-15T07:19:24.000+0000 |
| Affected Version/s | Release 1.6.0 |
| Fix Version/s | Sprint 2011-43, Release 1.8.0.1 |
| Components | Android |
| Labels | android, feature |
| Reporter | Ralf Pfeiffer |
| Assignee | Hieu Pham |
| Created | 2011-04-15T03:27:21.000+0000 |
| Updated | 2017-03-16T22:23:52.000+0000 |
Description
It appears that gzip headers arent currently supported.
xhr.setRequestHeader("Accept-Encoding","gzip,deflate");
Any chance of adding this? Thx!
http://stackoverflow.com/questions/1573391/android-http-communication-should-use-accept-encoding-gzip"> Possibly useful thread regarding supporting gzip compression on Android.
Associated Helpdesk Ticket
http://appc.me/c/APP-292662Bump. Would be a nice addition in 1.8
Folks this feature has been requested for over 6 months now. Gzipping on a slower network is key. Any chance to add this on in 1.8?
Any news on this is possible?
Would like to know if this is possible.
Steps to test: 1. Run the snippet
2. Run the snippet with and without this line and make sure content is identicalTi.UI.backgroundColor = '#dddddd'; var url = "https://raw.github.com/appcelerator/Documentation-Examples/master/HTTPClient/data/json.txt"; var win = Ti.UI.createWindow(); var table = Ti.UI.createTableView(); var tableData = []; var json, fighters, fighter, i, row, nameLabel, nickLabel; var xhr = Ti.Network.createHTTPClient({ onload: function() { // Ti.API.debug(this.responseText); json = JSON.parse(this.responseText); for (i = 0; i < json.fighters.length; i++) { fighter = json.fighters[i]; row = Ti.UI.createTableViewRow({ height:'60dp' }); nameLabel = Ti.UI.createLabel({ text:fighter.name, font:{ fontSize:'24dp', fontWeight:'bold' }, height:'auto', left:'10dp', top:'5dp', color:'#000', touchEnabled:false }); nickLabel = Ti.UI.createLabel({ text:'"' + fighter.nickname + '"', font:{ fontSize:'16dp' }, height:'auto', left:'15dp', bottom:'5dp', color:'#000', touchEnabled:false }); row.add(nameLabel); row.add(nickLabel); tableData.push(row); } table.setData(tableData); }, onerror: function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); }, timeout:5000 }); xhr.open("GET", url); xhr.setRequestHeader("Accept-Encoding","gzip,deflate"); xhr.send(); win.add(table); win.open();3. Since the json file we're getting info from is very small, you would not see performance difference, which is the main reason for gzipping. Perhaps feed in a bigger json thats 100k-200k large.xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");Keep up the good work on this, Hieu - it will be such a valuable addition.
I have evidence that this is working properly. 1. Upload the following to a public folder in your Dropbox: ~/Library/Applucation\ Support/Titanium/mobilesdk/1.8.0.1/api.jsca Dropbox supports gzip, and api.jsca is a 14mb JSON text file. 2. Drop the below snippet in an app.js and try it out. On my connection, I download the file in about 1.2 seconds. 3. For testing iOS, comment out gzip support in the SDK itself and try again. Also remove the setRequestHeader in your app.js. I averaged 8 seconds per download. We can extrapolate from this that gzip is transmitting a payload 15% the size of the uncompressed version. (Results may vary depending upon the data being transmitted.)
var start = new Date().getTime(); var client = Ti.Network.createHTTPClient({ onload: function () { alert('Request loaded in ' + (new Date().getTime() - start) + 'ms.'); }, onerror: function () { alert('Failed!'); } }); client.open('GET', 'http://dl.dropbox.com/u/<YOUR USER ID>/api.jsca'); client.setRequestHeader('Accept-Encoding', 'gzip,deflate'); client.send();it would be nice if 'Accept-Encoding: gzip,deflate' is added by default, because this is the behaviour when compiling for iOS
Closing ticket as fixed.