Giter VIP home page Giter VIP logo

Comments (5)

sandstrom avatar sandstrom commented on June 9, 2024 1

We should define a standard interface for compression algorithms.

I don't think rack should depend on another gem, but I have no problem exposing some standard mechanism that makes it extremely easy to pull in a zstd implementation and use it everywhere that makes sense.

I agree, this makes a lot of sense for several reasons!

Could be coupled with Rack docs pointing out a few third-party gems, or just examples of how to implement it.

from rack.

jeremyevans avatar jeremyevans commented on June 9, 2024 1

To support this and potentially other compression algorithms, I think we should provide a Deflater option for custom deflaters:

use Rack::Deflater, deflaters: {"zstd"=>lambda{|headers, body| ...}}

The callable would return the deflated body. The default would be something like:

{
  "gzip"=>lambda do |headers, body|
     mtime = headers["last-modified"]
     mtime = Time.httpdate(mtime).to_i if mtime
     GzipStream.new(body, mtime, @sync)
  },
  "identity"=>lambda{|headers, body| body}
}

Not saying the implementation would use that (should probably keep the current behavior hardcoded for performance), but that would be the behavior.

from rack.

ioquatix avatar ioquatix commented on June 9, 2024

Is there a standard library for providing this? I'd be okay with accepting a PR to implement this.

from rack.

sandstrom avatar sandstrom commented on June 9, 2024

@ioquatix This is the one I know about:

https://github.com/SpringMT/zstd-ruby

from rack.

ioquatix avatar ioquatix commented on June 9, 2024

I think the way I see this playing out:

  1. We should define a standard interface for compression algorithms.
  2. Define some way to specify the zstd as an option in Rack, e.g. require 'rack/deflater/zstd' or something.

I don't think rack should depend on another gem, but I have no problem exposing some standard mechanism that makes it extremely easy to pull in a zstd implementation and use it everywhere that makes sense.

from rack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.