summaryrefslogtreecommitdiff
path: root/lib/gitlab/http_io.rb
diff options
context:
space:
mode:
authorgfyoung <gfyoung17+gitlab@gmail.com>2018-10-22 07:00:50 +0000
committerRémy Coutable <remy@rymai.me>2018-10-22 07:00:50 +0000
commitc858f70d076dc44f6bf1ab1f7acb1fc13a12ab1b (patch)
tree40fa82826cf182f47b1c905e738c8ee955ad14c2 /lib/gitlab/http_io.rb
parent173b1436b1622b85d4a81e3577c6492cbb93a8b8 (diff)
downloadgitlab-ce-c858f70d076dc44f6bf1ab1f7acb1fc13a12ab1b.tar.gz
Enable frozen string for lib/gitlab/*.rb
Diffstat (limited to 'lib/gitlab/http_io.rb')
-rw-r--r--lib/gitlab/http_io.rb15
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)