Sha256: 037f72b53fbd1187ffea1731ba6064687ec516518815b01cf6ca661de4a41ad6

Contents?: true

Size: 839 Bytes

Versions: 10

Compression:

Stored size: 839 Bytes

Contents

# Rails use this to chunk it's streaming response body, which we don't need
module Rack
  class Chunked
    class Body
      def initialize(body)
        @body = body
      end

      def each
        @body.each {|chunk| yield chunk}
      end

      def close
        @body.close if @body.respond_to?(:close)
      end
    end

    include Rack::Utils

    def initialize(app)
      @app = app
    end

    def call(env)
      status, headers, body = @app.call(env)
      headers = HeaderHash.new(headers)

      unless env['HTTP_VERSION'] == 'HTTP/1.0' ||
           STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
           headers['Content-Length'] ||
           headers['Transfer-Encoding']
        headers.delete('Content-Length')
        headers.delete('Transfer-Encoding')
      end
      [status, headers, body]
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jubilee-2.1.0.Alpha1-java lib/rack/chunked.rb
jubilee-2.0.0-java lib/rack/chunked.rb
jubilee-2.0.0.beta-java lib/rack/chunked.rb
jubilee-2.0.0.alpha1-java lib/rack/chunked.rb
jubilee-1.1.3-java lib/rack/chunked.rb
jubilee-1.1.2-java lib/rack/chunked.rb
jubilee-1.1.0-java lib/rack/chunked.rb
jubilee-1.1.0.rc3 lib/rack/chunked.rb
jubilee-1.1.0.rc2 lib/rack/chunked.rb
jubilee-1.1.0.rc1 lib/rack/chunked.rb