about summary refs log tree commit homepage
path: root/lib/unicorn/const.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-02-05 14:30:29 -0800
committerEric Wong <normalperson@yhbt.net>2009-02-09 19:50:41 -0800
commitcda1f3381096cdb8c78a126a4993e458bf798ca2 (patch)
tree2cab13e70c2e7b72d87dc35a5b2b2ef7e92c0683 /lib/unicorn/const.rb
parentbf680b1a61ab17b6a0e17432fd4ab22358ec83bd (diff)
downloadunicorn-cda1f3381096cdb8c78a126a4993e458bf798ca2.tar.gz
Regenerating headers constantly is a waste of time.
Diffstat (limited to 'lib/unicorn/const.rb')
-rw-r--r--lib/unicorn/const.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb
index 8cefd2b..b44bb29 100644
--- a/lib/unicorn/const.rb
+++ b/lib/unicorn/const.rb
@@ -44,6 +44,12 @@ module Unicorn
     505  => 'HTTP Version not supported'
   }
 
+  HTTP_STATUS_HEADERS = HTTP_STATUS_CODES.inject({}) do |hash, (code, text)|
+    text.freeze
+    hash[code] = "HTTP/1.1 #{code} #{text}\r\nConnection: close\r\n".freeze
+    hash
+  end
+
   # Frequently used constants when constructing requests or responses.  Many times
   # the constant just refers to a string with the same contents.  Using these constants
   # gave about a 3% to 10% performance improvement over using the strings directly.
@@ -91,7 +97,6 @@ module Unicorn
     MAX_BODY=MAX_HEADER
 
     # A frozen format for this is about 15% faster
-    STATUS_FORMAT = "HTTP/1.1 %d %s\r\nConnection: close\r\n".freeze
     CONTENT_TYPE = "Content-Type".freeze
     LAST_MODIFIED = "Last-Modified".freeze
     ETAG = "ETag".freeze
@@ -109,4 +114,5 @@ module Unicorn
     REDIRECT = "HTTP/1.1 302 Found\r\nLocation: %s\r\nConnection: close\r\n\r\n".freeze
     HOST = "HOST".freeze
   end
+
 end