Sha256: 22c236cb2db053a43eafa218118a581462ac176302f0a7916acf6e62fe0c1afd

Contents?: true

Size: 736 Bytes

Versions: 8

Compression:

Stored size: 736 Bytes

Contents

# -*- encoding: binary -*-

module Pitchfork
  # This middleware is used to ensure input is buffered to memory
  # or disk (depending on size) before the application is dispatched
  # by entirely consuming it (from TeeInput) beforehand.
  #
  # Usage (in config.ru):
  #
  #     require 'pitchfork/preread_input'
  #     if defined?(Pitchfork)
  #       use Pitchfork::PrereadInput
  #     end
  #     run YourApp.new
  class PrereadInput

    # :stopdoc:
    def initialize(app)
      @app = app
    end

    def call(env)
      buf = ""
      input = env["rack.input"]
      if input.respond_to?(:rewind)
        true while input.read(16384, buf)
        input.rewind
      end
      @app.call(env)
    end
    # :startdoc:
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pitchfork-0.5.0 lib/pitchfork/preread_input.rb
pitchfork-0.4.1 lib/pitchfork/preread_input.rb
pitchfork-0.4.0 lib/pitchfork/preread_input.rb
pitchfork-0.3.0 lib/pitchfork/preread_input.rb
pitchfork-0.2.0 lib/pitchfork/preread_input.rb
pitchfork-0.1.2 lib/pitchfork/preread_input.rb
pitchfork-0.1.1 lib/pitchfork/preread_input.rb
pitchfork-0.1.0 lib/pitchfork/preread_input.rb