# File lib/composite_io.rb, line 24
  def read(length = nil, outbuf = nil)
    got_result = false
    outbuf = outbuf ? outbuf.replace("") : ""

    while io = current_io
      if result = io.read(length)
        got_result ||= !result.nil?
        result.force_encoding("BINARY") if result.respond_to?(:force_encoding)
        outbuf << result
        length -= result.length if length
        break if length == 0
      end
      advance_io
    end
    (!got_result && length) ? nil : outbuf
  end