Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2698] Support for "Accept-Encoding","gzip,deflate"

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-11-15T07:19:24.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sSprint 2011-43, Release 1.8.0.1
ComponentsAndroid
Labelsandroid, feature
ReporterRalf Pfeiffer
AssigneeHieu Pham
Created2011-04-15T03:27:21.000+0000
Updated2017-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!

Comments

  1. kevinwhinnery 2011-04-15

    http://stackoverflow.com/questions/1573391/android-http-communication-should-use-accept-encoding-gzip"> Possibly useful thread regarding supporting gzip compression on Android.

  2. Jon Alter 2011-06-17

    Associated Helpdesk Ticket

    http://appc.me/c/APP-292662
  3. Jeff Haynie 2011-07-14

    Bump. Would be a nice addition in 1.8
  4. Taazza GO 2011-09-15

    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?
  5. Rick Blalock 2011-10-18

    Any news on this is possible?
  6. Rick Blalock 2011-10-25

    Would like to know if this is possible.
  7. Hieu Pham 2011-10-26

    Steps to test: 1. Run the snippet
       Ti.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();
       
    2. Run the snippet with and without this line and make sure content is identical
       xhr.setRequestHeader("Accept-Encoding", "gzip,deflate");
       
    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.
  8. Paul Dowsett 2011-10-30

    Keep up the good work on this, Hieu - it will be such a valuable addition.
  9. Dawson Toth 2012-03-02

    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();
       
  10. carlo 2014-10-10

    it would be nice if 'Accept-Encoding: gzip,deflate' is added by default, because this is the behaviour when compiling for iOS
  11. Lee Morris 2017-03-16

    Closing ticket as fixed.

JSON Source