about summary refs log tree commit homepage
path: root/lib/yahns/http_response.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/http_response.rb')
-rw-r--r--lib/yahns/http_response.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb
index b70491d..f50c9a1 100644
--- a/lib/yahns/http_response.rb
+++ b/lib/yahns/http_response.rb
@@ -23,13 +23,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   # avoid GC overhead for frequently used-strings:
-  CONN_KA = "Connection: keep-alive\r\n\r\n"
-  CONN_CLOSE = "Connection: close\r\n\r\n"
-  Z = ""
   CCC_RESPONSE_START = [ 'HTTP', '/1.1 ' ]
-  RESPONSE_START = CCC_RESPONSE_START.join
-  REQUEST_METHOD = "REQUEST_METHOD"
-  HEAD = "HEAD"
 
   # no point in using one without the other, these have been in Linux
   # for ages
@@ -46,7 +40,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   def response_start
-    @hs.response_start_sent ? Z : RESPONSE_START
+    @hs.response_start_sent ? ''.freeze : 'HTTP/1.1 '.freeze
   end
 
   def response_wait_write(rv)
@@ -115,7 +109,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   def kv_str(key, value)
-    if value =~ /\n/
+    if value.include?("\n".freeze)
       # avoiding blank, key-only cookies with /\n+/
       value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" }.join
     else
@@ -124,7 +118,7 @@ module Yahns::HttpResponse # :nodoc:
   end
 
   def have_more?(value)
-    value.to_i > 0 && @hs.env[REQUEST_METHOD] != HEAD
+    value.to_i > 0 && @hs.env['REQUEST_METHOD'] != 'HEAD'.freeze
   end
 
   # writes the rack_response to socket as an HTTP response
@@ -163,7 +157,8 @@ module Yahns::HttpResponse # :nodoc:
           buf << kv_str(key, value)
         end
       end
-      buf << (alive ? CONN_KA : CONN_CLOSE)
+      buf << (alive ? "Connection: keep-alive\r\n\r\n".freeze
+                    : "Connection: close\r\n\r\n".freeze)
       case rv = kgio_syssend(buf, flags)
       when nil # all done, likely
         break