From 36d02e26fc627fe431bfedc740b80dde75665987 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 12 May 2009 20:48:46 +0000 Subject: Require Rack for HTTP Status codes Preventing needless duplication since Rack already has these codes for us. Also, put the status codes in HttpResponse since nothing else needs (or should need) them. --- lib/unicorn/http_response.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/unicorn/http_response.rb') diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index a9b5f2b..ce04a0d 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -21,6 +21,12 @@ module Unicorn class HttpResponse + # Every standard HTTP code mapped to the appropriate message. + CODES = Rack::Utils::HTTP_STATUS_CODES.inject({}) { |hash,(code,msg)| + hash[code] = "#{code} #{msg}" + hash + } + # Rack does not set/require a Date: header. We always override the # Connection: and Date: headers no matter what (if anything) our # Rack application sent us. @@ -31,7 +37,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 = HTTP_STATUS_CODES[status] + status = CODES[status] OUT.clear # Don't bother enforcing duplicate supression, it's a Hash most of -- cgit v1.2.3-24-ge0c7