diff options
Diffstat (limited to 'lib/yahns/proxy_http_response.rb')
-rw-r--r-- | lib/yahns/proxy_http_response.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb index 3858456..bfd6501 100644 --- a/lib/yahns/proxy_http_response.rb +++ b/lib/yahns/proxy_http_response.rb @@ -1,6 +1,7 @@ # -*- encoding: binary -*- # Copyright (C) 2015 all contributors <yahns-public@yhbt.net> # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true # loaded by yahns/proxy_pass, this relies on Yahns::HttpResponse for # constants. @@ -69,7 +70,7 @@ module Yahns::HttpResponse # :nodoc: alive = @hs.next? && self.class.persistent_connections response_headers = env['yahns.proxy_pass.response_headers'] - res = "HTTP/1.1 #{msg ? %Q(#{code} #{msg}) : status}\r\n" + res = "HTTP/1.1 #{msg ? %Q(#{code} #{msg}) : status}\r\n".dup headers.each do |key,value| # n.b.: headers is an Array of 2-element Arrays case key when /\A(?:Connection|Keep-Alive)\z/i @@ -123,7 +124,7 @@ module Yahns::HttpResponse # :nodoc: elsif kcar.chunked? # nasty chunked body req_res.proxy_trailers = nil # define to avoid warnings for now - buf = '' + buf = ''.dup case tmp = tip.shift || req_res.kgio_tryread(0x2000, rbuf) when String kcar.filter_body(buf, tmp) @@ -136,7 +137,7 @@ module Yahns::HttpResponse # :nodoc: buf = tmp req_res.proxy_trailers = [ buf, tlr = [] ] - rbuf = Thread.current[:yahns_rbuf] = '' + rbuf = Thread.current[:yahns_rbuf] = ''.dup until kcar.trailers(tlr, buf) case rv = req_res.kgio_tryread(0x2000, rbuf) when String @@ -186,7 +187,7 @@ module Yahns::HttpResponse # :nodoc: end while len != 0 elsif kcar.chunked? # nasty chunked body - buf = '' + buf = ''.dup unless req_res.proxy_trailers # are we done dechunking the main body, yet? @@ -200,7 +201,7 @@ module Yahns::HttpResponse # :nodoc: return :wait_readable # self remains in :ignore, wait on upstream end until kcar.body_eof? req_res.proxy_trailers = [ tmp, [] ] # onto trailers! - rbuf = Thread.current[:yahns_rbuf] = '' + rbuf = Thread.current[:yahns_rbuf] = ''.dup end buf, tlr = *req_res.proxy_trailers |