class Rack::Lint::Wrapper::InputWrapper

def close(*args)

# * +close+ can be called on the input stream to indicate that any remaining input is not needed.
def close(*args)
  @input.close(*args)
end

def each(*args)

# * +each+ must be called without arguments and only yield +String+ values.
def each(*args)
  raise LintError, "rack.input#each called with arguments" unless args.size == 0
  @input.each do |line|
    unless line.kind_of? String
      raise LintError, "rack.input#each didn't yield a String"
    end
    yield line
  end
end

def gets(*args)

# * +gets+ must be called without arguments and return a +String+, or +nil+ on EOF (end-of-file).
def gets(*args)
  raise LintError, "rack.input#gets called with arguments" unless args.size == 0
  chunk = @input.gets
  unless chunk.nil? or chunk.kind_of? String
    raise LintError, "rack.input#gets didn't return a String"
  end
  chunk
end

def initialize(input)

def initialize(input)
  @input = input
end

def read(*args)

# * If +buffer+ is given, then the read data will be placed into +buffer+ instead of a newly created +String+.
# * When EOF is reached, this method returns +nil+ if +length+ is given and not +nil+, or +""+ if +length+ is not given or is +nil+.
# * If +length+ is not given or +nil+, then this method reads all data until EOF.
# * If +length+ is given and not +nil+, then this method reads at most +length+ bytes from the input stream.
# * If given, +length+ must be a non-negative Integer (>= 0) or +nil+, and +buffer+ must be a +String+ and may not be +nil+.
# * +read+ behaves like IO#read. Its signature is read([length, [buffer]]).
def read(*args)
  unless args.size <= 2
    raise LintError, "rack.input#read called with too many arguments"
  end
  if args.size >= 1
    unless args.first.kind_of?(Integer) || args.first.nil?
      raise LintError, "rack.input#read called with non-integer and non-nil length"
    end
    unless args.first.nil? || args.first >= 0
      raise LintError, "rack.input#read called with a negative length"
    end
  end
  if args.size >= 2
    unless args[1].kind_of?(String)
      raise LintError, "rack.input#read called with non-String buffer"
    end
  end
  chunk = @input.read(*args)
  unless chunk.nil? or chunk.kind_of? String
    raise LintError, "rack.input#read didn't return nil or a String"
  end
  if args[0].nil?
    unless !chunk.nil?
      raise LintError, "rack.input#read(nil) returned nil on EOF"
    end
  end
  chunk
end