diff options
Diffstat (limited to 'lib/gitlab/http_io.rb')
-rw-r--r-- | lib/gitlab/http_io.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/gitlab/http_io.rb b/lib/gitlab/http_io.rb index ce24817db54..9d7763fc5ac 100644 --- a/lib/gitlab/http_io.rb +++ b/lib/gitlab/http_io.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ## # This class is compatible with IO class (https://ruby-doc.org/core-2.3.1/IO.html) # source: https://gitlab.com/snippets/1685610 @@ -73,8 +75,8 @@ module Gitlab end end - def read(length = nil, outbuf = "") - out = "" + def read(length = nil, outbuf = nil) + out = [] length ||= size - tell @@ -90,17 +92,18 @@ module Gitlab length -= chunk_data.bytesize end + out = out.join + # If outbuf is passed, we put the output into the buffer. This supports IO.copy_stream functionality if outbuf - outbuf.slice!(0, outbuf.bytesize) - outbuf << out + outbuf.replace(out) end out end def readline - out = "" + out = [] until eof? data = get_chunk @@ -116,7 +119,7 @@ module Gitlab end end - out + out.join end def write(data) |