def to_string_io
      content = StringIO.new
      while bytes = read and !bytes.empty?
        content.write( bytes )
      end
      content.rewind
      content
    end
def to_string_io
      content = StringIO.new
      while bytes = read and !bytes.empty?
        content.write( bytes )
      end
      content.rewind
      content
    end
reads the stream contents into a StringIO object