diff options
author | Eric Wong <e@80x24.org> | 2015-11-14 02:47:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-11-18 02:20:25 +0000 |
commit | 70c976bdd85bb8515fea01d6ad6074ef472fc2e0 (patch) | |
tree | 51230dc24bb183176b932e0d38e181869b5485e7 /lib/rainbows/dev_fd_response.rb | |
parent | 9c9e3949b2ef2f299ff1590d23aa4d053b60a2fd (diff) | |
download | rainbows-70c976bdd85bb8515fea01d6ad6074ef472fc2e0.tar.gz |
Unicorn 5 removes some constants we were using, and constant lookups + inline caching are waste of time anyways on newer Rubies with the opt_str_freeze bytecode instruction. This may reduce performance for folks on older Rubies (probably not noticeable); but improves performance for folks on newer Rubies.
Diffstat (limited to 'lib/rainbows/dev_fd_response.rb')
-rw-r--r-- | lib/rainbows/dev_fd_response.rb | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/rainbows/dev_fd_response.rb b/lib/rainbows/dev_fd_response.rb index 7baccfc..8ebaabd 100644 --- a/lib/rainbows/dev_fd_response.rb +++ b/lib/rainbows/dev_fd_response.rb @@ -11,12 +11,6 @@ class Rainbows::DevFdResponse < Struct.new(:app) # :stopdoc: FD_MAP = Rainbows::FD_MAP - Content_Length = "Content-Length".freeze - Transfer_Encoding = "Transfer-Encoding".freeze - Rainbows_autochunk = "rainbows.autochunk".freeze - Rainbows_model = "rainbows.model" - HTTP_VERSION = "HTTP_VERSION" - Chunked = "chunked" include Rack::Utils # Rack middleware entry point, we'll just pass through responses @@ -40,23 +34,23 @@ class Rainbows::DevFdResponse < Struct.new(:app) fileno = io.fileno FD_MAP[fileno] = io if st.file? - headers[Content_Length] ||= st.size.to_s - headers.delete(Transfer_Encoding) + headers['Content-Length'.freeze] ||= st.size.to_s + headers.delete('Transfer-Encoding'.freeze) elsif st.pipe? || st.socket? # epoll-able things - unless headers.include?(Content_Length) - if env[Rainbows_autochunk] - case env[HTTP_VERSION] + unless headers.include?('Content-Length'.freeze) + if env['rainbows.autochunk'] + case env['HTTP_VERSION'] when "HTTP/1.0", nil else - headers[Transfer_Encoding] = Chunked + headers['Transfer-Encoding'.freeze] = 'chunked' end else - env[Rainbows_autochunk] = false + env['rainbows.autochunk'] = false end end # we need to make sure our pipe output is Fiber-compatible - case env[Rainbows_model] + case env['rainbows.model'] when :FiberSpawn, :FiberPool, :RevFiberSpawn, :CoolioFiberSpawn io.respond_to?(:kgio_wait_readable) or io = Rainbows::Fiber::IO.new(io) |