### Home Classes Methods

### In Files

- lib/rack/rewindable_input.rb

### Parent

Object

### Namespace

- CLASS Rack::RewindableInput::Tempfile

### Methods

- ::new
- #close
- #each
- #gets
- #read
- #rewind

### Files

- KNOWN-ISSUES

### Class/Module Index

Quicksearch

- Rack
- Rack::Auth
- Rack::Auth::AbstractHandler
- Rack::Auth::AbstractRequest
- Rack::Auth::Basic
- Rack::Auth::Basic::Request
- Rack::Auth::Digest
- Rack::Auth::Digest::MD5
- Rack::Auth::Digest::Nonce
- Rack::Auth::Digest::Params
- Rack::Auth::Digest::Request
- Rack::BodyProxy
- Rack::Builder
- Rack::Cascade
- Rack::Chunked
- Rack::Chunked::Body
- Rack::CommonLogger
- Rack::ConditionalGet
- Rack::Config
- Rack::ContentLength
- Rack::ContentType
- Rack::Deflater
- Rack::Deflater::DeflateStream
- Rack::Deflater::GzipStream
- Rack::Directory
- Rack::ETag
- Rack::File
- Rack::ForwardRequest
- Rack::Handler
- Rack::Handler::CGI
- Rack::Handler::EventedMongrel
- Rack::Handler::FastCGI
- Rack::Handler::LSWS
- Rack::Handler::Mongrel
- Rack::Handler::SCGI
- Rack::Handler::SwiftipliedMongrel
- Rack::Handler::Thin
- Rack::Handler::WEBrick
- Rack::Head
- Rack::Lint
- Rack::Lobster
- Rack::Lock
- Rack::Logger
- Rack::MethodOverride
- Rack::Mime
- Rack::MockRequest
- Rack::MockRequest::FatalWarner
- Rack::MockRequest::FatalWarning
- Rack::MockResponse
- Rack::Multipart
- Rack::Multipart::Generator
- Rack::Multipart::MultipartPartLimitError
- Rack::Multipart::Parser
- Rack::Multipart::UploadedFile
- Rack::NullLogger
- Rack::Recursive
- Rack::Reloader
- Rack::Reloader::Stat
- Rack::Request
- Rack::Response
- Rack::Response::Helpers
- Rack::RewindableInput
- Rack::RewindableInput::Tempfile
- Rack::Runtime
- Rack::Sendfile
- Rack::Server
- Rack::Server::Options
- Rack::Session
- Rack::Session::Abstract
- Rack::Session::Abstract::ID
- Rack::Session::Abstract::SessionHash
- Rack::Session::Cookie
- Rack::Session::Cookie::Base64
- Rack::Session::Cookie::Base64::JSON
- Rack::Session::Cookie::Base64::Marshal
- Rack::Session::Cookie::Base64::ZipJSON
- Rack::Session::Cookie::Identity
- Rack::Session::Memcache
- Rack::Session::Pool
- Rack::ShowExceptions
- Rack::ShowStatus
- Rack::Static
- Rack::TempfileReaper
- Rack::URLMap
- Rack::Utils
- Rack::Utils::Context
- Rack::Utils::HeaderHash
- Rack::Utils::InvalidParameterError
- Rack::Utils::KeySpaceConstrainedParams
- Rack::Utils::Multipart
- Rack::Utils::OkJson
- Rack::Utils::OkJson::Error
- Rack::Utils::OkJson::Utf8Error
- Rack::Utils::ParameterTypeError
- FCGI
- FCGI::Stream
- WEBrick
- WEBrick::HTTPResponse
- Object

No matching classes.

# Rack::RewindableInput

Class which can make any IO object rewindable, including non-rewindable ones. It does this by buffering the data into a tempfile, which is rewindable.

rack.input is required to be rewindable, so if your input stream IO is non-rewindable by nature (e.g. a pipe or a socket) then you can wrap it in an object of this class to easily make it rewindable.

Don't forget to call close when you're done. This frees up temporary resources that RewindableInput uses, though it does not close the original IO object.

### Public Class Methods

new(io) click to toggle source

    # File lib/rack/rewindable_input.rb, line 15
    def initialize(io)
      @io = io
      @rewindable_io = nil
      @unlinked = false
    end

### Public Instance Methods

close() click to toggle source

Closes this RewindableInput object without closing the originally wrapped IO oject. Cleans up any temporary resources that this RewindableInput has created.

This method may be called multiple times. It does nothing on subsequent calls.

    # File lib/rack/rewindable_input.rb, line 46
    def close
      if @rewindable_io
        if @unlinked
          @rewindable_io.close
        else
          @rewindable_io.close!
        end
        @rewindable_io = nil
      end
    end

each(&block) click to toggle source

    # File lib/rack/rewindable_input.rb, line 31
    def each(&block)
      make_rewindable unless @rewindable_io
      @rewindable_io.each(&block)
    end

gets() click to toggle source

    # File lib/rack/rewindable_input.rb, line 21
    def gets
      make_rewindable unless @rewindable_io
      @rewindable_io.gets
    end

read(*args) click to toggle source

    # File lib/rack/rewindable_input.rb, line 26
    def read(*args)
      make_rewindable unless @rewindable_io
      @rewindable_io.read(*args)
    end

rewind() click to toggle source

    # File lib/rack/rewindable_input.rb, line 36
    def rewind
      make_rewindable unless @rewindable_io
      @rewindable_io.rewind
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.