diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-08-14 21:03:45 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-08-15 02:38:48 -0700 |
commit | a109f7537a0527282308ac87aea6e54fb135054c (patch) | |
tree | 24035540189ec275fcaa302bf8ffebe67790fc00 | |
parent | bd8f086963d193ec91a549361938f2d3497f8f4d (diff) | |
download | unicorn-a109f7537a0527282308ac87aea6e54fb135054c.tar.gz |
This lets clients can pass through newly-invented status codes that Rack does not know about.
-rw-r--r-- | lib/unicorn/http_response.rb | 2 | ||||
-rw-r--r-- | test/unit/test_response.rb | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index bfaa33d..5602a43 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -36,7 +36,7 @@ module Unicorn # writes the rack_response to socket as an HTTP response def self.write(socket, rack_response) status, headers, body = rack_response - status = CODES[status.to_i] + status = CODES[status.to_i] || status OUT.clear # Don't bother enforcing duplicate supression, it's a Hash most of diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb index 66c2b54..0c4d29e 100644 --- a/test/unit/test_response.rb +++ b/test/unit/test_response.rb @@ -94,4 +94,15 @@ class ResponseTest < Test::Unit::TestCase assert_match(expect_body, out.string.split(/\r\n/).last) end + def test_unknown_status_pass_through + out = StringIO.new + HttpResponse.write(out,["666 I AM THE BEAST", {}, [] ]) + assert out.closed? + headers = out.string.split(/\r\n\r\n/).first.split(/\r\n/) + assert %r{\AHTTP/\d\.\d 666 I AM THE BEAST\z}.match(headers[0]) + status = headers.grep(/\AStatus:/i).first + assert status + assert_equal "Status: 666 I AM THE BEAST", status + end + end |