# File lib/phusion_passenger/utils/tee_input.rb, line 127
  def read(len = nil, buf = "")
    buf ||= ""
    if len
      if len < 0
        raise ArgumentError, "negative length #{len} given"
      elsif len == 0
        buf.replace('')
        buf
      else
        if socket_drained?
          @tmp.read(len, buf)
        else
          tee(read_exact(len, buf))
        end
      end
    else
      if socket_drained?
        @tmp.read(nil, buf)
      else
        tee(read_all(buf))
      end
    end
  end