diff --git a/lib/httpclient.rb b/lib/httpclient.rb index e1f1864..e844909 100644 --- a/lib/httpclient.rb +++ b/lib/httpclient.rb @@ -1240,7 +1240,7 @@ def do_get_block(req, proxy, conn, &block) conn.push(res) return res end - content = block ? nil : '' + content = block ? nil : ''.dup res = HTTP::Message.new_response(content, req.header) @debug_dev << "= Request\n\n" if @debug_dev sess = @session_manager.query(req, proxy) diff --git a/lib/httpclient/http.rb b/lib/httpclient/http.rb index f6a8607..0fdedb5 100644 --- a/lib/httpclient/http.rb +++ b/lib/httpclient/http.rb @@ -574,7 +574,7 @@ def reset_pos(io) end def dump_file(io, dev, sz) - buf = '' + buf = ''.dup rest = sz while rest > 0 n = io.read([rest, @chunk_size].min, buf) diff --git a/lib/httpclient/session.rb b/lib/httpclient/session.rb index 67e2c3b..8cb09d4 100644 --- a/lib/httpclient/session.rb +++ b/lib/httpclient/session.rb @@ -950,7 +950,7 @@ def read_body_rest end def empty_bin_str - str = '' + str = ''.dup str.force_encoding('BINARY') if str.respond_to?(:force_encoding) str end diff --git a/lib/httpclient/util.rb b/lib/httpclient/util.rb index 6ff3801..9b93035 100644 --- a/lib/httpclient/util.rb +++ b/lib/httpclient/util.rb @@ -64,7 +64,7 @@ class AddressableURI < Addressable::URI # Overwrites the original definition just for one line... def authority self.host && @authority ||= (begin - authority = "" + authority = "".dup if self.userinfo != nil authority << "#{self.userinfo}@" end