diff options
author | Eric Wong <e@80x24.org> | 2016-01-02 22:29:12 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-01-02 22:29:28 +0000 |
commit | 9e24bae3428f726800da2963a8f2695f7d4064cd (patch) | |
tree | dd4ce29efffa4f0da9c6d9ada903a277ec81196b /extras/proxy_pass.rb | |
parent | 1105a6957eed26a922a27bd6e6dbbc457524b664 (diff) | |
download | yahns-9e24bae3428f726800da2963a8f2695f7d4064cd.tar.gz |
There are likely yet-to-be-discovered bugs in here. Also, keeping explicit #freeze calls for 2.2 users, since most users have not migrated to 2.3, yet.
Diffstat (limited to 'extras/proxy_pass.rb')
-rw-r--r-- | extras/proxy_pass.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb index 29dd995..ca5a6b2 100644 --- a/extras/proxy_pass.rb +++ b/extras/proxy_pass.rb @@ -1,6 +1,7 @@ # -*- encoding: binary -*- # Copyright (C) 2013-2015 all contributors <yahns-public@yhbt.net> # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# frozen_string_literal: true require 'time' require 'socket' require 'kgio' @@ -45,7 +46,7 @@ class ProxyPass # :nodoc: tout end - def readpartial(bytes, buf = Thread.current[:proxy_pass_buf] ||= "") + def readpartial(bytes, buf = Thread.current[:proxy_pass_buf] ||= ''.dup) case rv = kgio_read!(bytes, buf) when String @expiry += @timeout # bump expiry when we succeed @@ -145,7 +146,7 @@ class ProxyPass # :nodoc: req = Rack::Request.new(env) path = @path.gsub(/\$(\w+)/) { req.__send__($1) } req = "#{request_method} #{path} HTTP/1.1\r\n" \ - "X-Forwarded-For: #{env["REMOTE_ADDR"]}\r\n" + "X-Forwarded-For: #{env["REMOTE_ADDR"]}\r\n".dup # pass most HTTP_* headers through as-is chunked = false @@ -198,7 +199,7 @@ class ProxyPass # :nodoc: end def send_body(input, ures, chunked) - buf = Thread.current[:proxy_pass_buf] ||= "" + buf = Thread.current[:proxy_pass_buf] ||= ''.dup if chunked # unlikely while input.read(16384, buf) |