From ef02631a26bd29f8930585f207839bf35f2bf1e8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Dec 2009 00:09:40 -0800 Subject: set env["rack.logger"] for applications rack.git upstream has it, so it will likely be in Rack 1.1 --- lib/unicorn.rb | 4 ++++ test/unit/test_server.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 71d5994..cf58165 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -249,6 +249,10 @@ module Unicorn def stdout_path=(path); redirect_io($stdout, path); end def stderr_path=(path); redirect_io($stderr, path); end + def logger=(obj) + HttpRequest::DEFAULTS["rack.logger"] = super + end + # sets the path for the PID file of the master process def pid=(path) if path diff --git a/test/unit/test_server.rb b/test/unit/test_server.rb index 55147b7..00705d0 100644 --- a/test/unit/test_server.rb +++ b/test/unit/test_server.rb @@ -228,6 +228,16 @@ class WebServerTest < Test::Unit::TestCase end end + def test_logger_set + assert_equal @server.logger, Unicorn::HttpRequest::DEFAULTS["rack.logger"] + end + + def test_logger_changed + tmp = Logger.new($stdout) + @server.logger = tmp + assert_equal tmp, Unicorn::HttpRequest::DEFAULTS["rack.logger"] + end + def test_bad_client_400 sock = nil assert_nothing_raised do -- cgit v1.2.3-24-ge0c7 From 53b53c7d2e8c4fe6ef30184782bd7ab466becf19 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Dec 2009 15:39:29 -0800 Subject: bump "rack.version" env to [1,1] This will match what's in Rack the 1.1.0 release. --- lib/unicorn/http_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index 31fcc3d..99c11c2 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -12,7 +12,7 @@ module Unicorn "rack.multiprocess" => true, "rack.multithread" => false, "rack.run_once" => false, - "rack.version" => [1, 0], + "rack.version" => [1, 1], "SCRIPT_NAME" => "", # this is not in the Rack spec, but some apps may rely on it -- cgit v1.2.3-24-ge0c7 From 8da4448c7117759b0fb8ea8e4243e81ea8b26e7c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 5 Jan 2010 17:17:00 -0800 Subject: local.mk.sample: use rack-1.1.0 --- local.mk.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local.mk.sample b/local.mk.sample index 1746320..2b331fc 100644 --- a/local.mk.sample +++ b/local.mk.sample @@ -5,7 +5,7 @@ # This is depends on a bunch of GNU-isms from bash, sed, touch. DLEXT := so -gems := rack-1.0.1 +gems := rack-1.1.0 # Avoid loading rubygems to speed up tests because gmake is # fork+exec heavy with Ruby. -- cgit v1.2.3-24-ge0c7 From 52400de1c9e9437b5c9df899f273485f663bb5b5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 5 Jan 2010 17:36:17 -0800 Subject: http_response: disallow blank, multi-value headers The HeaderHash optimizations in Rack 1.1 interact badly with Rails 2.3.5 (and possibly other frameworks/apps) which set multi-value "Set-Cookie" headers without relying on the proper methods provided by Rack::Utils. While this is an issue with Rails not using properly, there may be similar apps that make this mistake and Rack::Lint does not guard against it. Rack-ML-Ref: <20100105235845.GB3377@dcvr.yhbt.net> --- lib/unicorn/http_response.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index 92d4d6d..96e484b 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -47,7 +47,8 @@ module Unicorn headers.each do |key, value| next if SKIP.include?(key.downcase) if value =~ /\n/ - out.concat(value.split(/\n/).map! { |v| "#{key}: #{v}\r\n" }) + # avoiding blank, key-only cookies with /\n+/ + out.concat(value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" }) else out << "#{key}: #{value}\r\n" end -- cgit v1.2.3-24-ge0c7