Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Gzip / Deflate support for ActiveResource

#2070

At the moment ActiveResource does not support gzip/deflate. As it does use XML as a transfer medium, this becomes highly inefficient with large datasets.

Gzip is one of the oldest remedies for this, and all major application servers for rails support it, but activeresource doesn't.

To enable: have ZLib installed and add this tou your ActiveResource base class: base.headers['Accept-Encoding'] = 'deflate'

Reported by Bart ten Brinke · February 25th, 2009 @ 01:16 PM

State: stale
Milestone: 3.x
Assigned to: Rick Rick
Importance: none

Activity

  1. José Valim
  2. Rob Sanheim
  3. Michael Koziarski
    Michael Koziarski
    • Assigned user set to Rick

    March 2nd, 2009 @ 05:26 AM

  4. Bart ten Brinke
    Bart ten Brinke
    • Tag changed from activeresource, patch to activeresource, patch, verified

    Can this be included in 2.3? Would be a nice combination with the XML parsers.

    March 10th, 2009 @ 07:10 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open

    This is cool, but how are you passing Accept-Encoding in the first place?

    Too late for 2.3 as we're down to the final release candidate.

    March 10th, 2009 @ 08:25 PM

  6. Bart ten Brinke
    Bart ten Brinke

    Last line of the ticket:

    To enable add this to your ActiveResource base class via a Mixin: base.headers['Accept-Encoding'] = 'deflate'

    March 10th, 2009 @ 09:44 PM

  7. Bart ten Brinke
    Bart ten Brinke

    Is zlib packed with Rails 2.3? Because that will allow for some simplification of the patch. Too bad it's to late for 2.3.

    March 10th, 2009 @ 09:48 PM

  8. Jeremy Kemper
    Jeremy Kemper

    zlib is part of the ruby standard library

    March 10th, 2009 @ 10:17 PM

  9. Bart ten Brinke
    Bart ten Brinke

    Doh :) Repackaged. More tests + added an ActiveResource.enable_delfate option to set the headers for you.

    March 10th, 2009 @ 11:33 PM

  10. ronin-57396 (at lighthouseapp)
  11. Jeremy Kemper
    Jeremy Kemper

    Prefer not adding inflate! to net/http since it inflates AS for a special case. Could you use a utility method on the connection instead?

    May 19th, 2009 @ 08:26 PM

  12. Bart ten Brinke
    Bart ten Brinke

    Gzip is something that really belongs in net/http as it is something you do to a packet.

    May 19th, 2009 @ 09:13 PM

  13. Bart ten Brinke
    Bart ten Brinke

    Also I think net http should really support this as every thing that does http transfers will benefit from this.

    May 19th, 2009 @ 09:15 PM

  14. Jeremy Kemper
    Jeremy Kemper

    It should, but that feature should be a patch to upstream net/http rather than hiding out in Active Support.

    Then Active Resource can either use net/http's inflate support or fall back to its own utility method.

    May 19th, 2009 @ 10:00 PM

  15. Bart ten Brinke
    Bart ten Brinke

    Problem is that body is a private attribute of HTTP::NET, so if all the magick is in AR, it would make the patch even more ugly.

    May 19th, 2009 @ 11:07 PM

  16. Dean Radcliffe
    Dean Radcliffe

    Jeremy mentions both:

    Prefer not adding inflate! to net/http since it inflates AS for a special case. then..
    that feature should be a patch to upstream net/http

    I hope this one makes it in somewhere. Theres zero performance penalty of having this option turned off, and the ability to shorten average request duration if turned on. It meets good usability standards as well.

    D

    August 14th, 2009 @ 06:00 AM

  17. Bart ten Brinke
    Bart ten Brinke

    I don't really understand the problem with patching HTTP:NET. They will probably never do it upstream because of the zlib requirements. Also rails already has a truckload of mix-ins for base ruby classes (take hash for example).

    And as stated above. There is no penalty if left disabled.

    August 14th, 2009 @ 07:44 AM

  18. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  19. Santiago Pastorino
    Santiago Pastorino
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:41 PM

  20. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:41 PM