### Home Classes Methods

### In Files

- lib/phusion_passenger/utils/tee_input.rb

### Parent

Object

### Methods

- ::client_body_buffer_size
- ::client_body_buffer_size=
- ::new
- #close
- #each
- #gets
- #read
- #rewind
- #size

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# PhusionPassenger::Utils::TeeInput

acts like tee(1) on an input input to provide a input-like stream while providing rewindable semantics through a File/StringIO backing store. On the first pass, the input is only read on demand so your Rack application can use input notification (upload progress and like). This should fully conform to the Rack::Lint::InputWrapper specification on the public API. This class is intended to be a strict interpretation of Rack::Lint::InputWrapper functionality and will not support any deviations from it.

When processing uploads, Unicorn exposes a TeeInput object under "rack.input" of the Rack environment.

### Constants

CONTENT_LENGTH

### Public Class Methods

client_body_buffer_size() click to toggle source

returns the maximum size of request bodies to buffer in memory, amounts larger than this are buffered to the filesystem

    # File lib/phusion_passenger/utils/tee_input.rb, line 87
    def self.client_body_buffer_size
      @@client_body_buffer_size
    end

client_body_buffer_size=(bytes) click to toggle source

sets the maximum size of request bodies to buffer in memory, amounts larger than this are buffered to the filesystem

    # File lib/phusion_passenger/utils/tee_input.rb, line 81
    def self.client_body_buffer_size=(bytes)
      @@client_body_buffer_size = bytes
    end

new(socket, env) click to toggle source

Initializes a new TeeInput object. You normally do not have to call this unless you are writing an HTTP server.

    # File lib/phusion_passenger/utils/tee_input.rb, line 93
    def initialize(socket, env)
      @len = env[CONTENT_LENGTH]
      @len = @len.to_i if @len
      @socket = socket
      @tmp = @len && @len <= @@client_body_buffer_size ?
             StringIO.new("") : TmpIO.new("PassengerTeeInput")
    end

### Public Instance Methods

close() click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 101
    def close
      @tmp.close
    end

each() click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 135
    def each
      while line = gets
        yield line
      end

      self # Rack does not specify what the return value is here
    end

gets() click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 121
    def gets
      if socket_drained?
        @tmp.gets
      else
        tee(@socket.gets)
      end
    end

read(*args) click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 113
    def read(*args)
      if socket_drained?
        @tmp.read(*args)
      else
        tee(@socket.read(*args))
      end
    end

rewind() click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 129
    def rewind
      return 0 if 0 == @tmp.size
      consume! if !socket_drained?
      @tmp.rewind # Rack does not specify what the return value is here
    end

size() click to toggle source

    # File lib/phusion_passenger/utils/tee_input.rb, line 105
    def size
      @len and return @len
      pos = @tmp.pos
      consume!
      @tmp.pos = pos
      @len = @tmp.size
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.