about summary refs log tree commit homepage
path: root/lib/yahns/proxy_http_response.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/proxy_http_response.rb')
-rw-r--r--lib/yahns/proxy_http_response.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index cbdce6f..61989c2 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -38,7 +38,8 @@ module Yahns::HttpResponse # :nodoc:
     end
     # try to write something, but don't care if we fail
     Integer === code and
-      kgio_trywrite("HTTP/1.1 #{CODES[code]}\r\n\r\n") rescue nil
+      kgio_trywrite("HTTP/1.1 #{code} #{
+                     Rack::Utils::HTTP_STATUS_CODES[code]}\r\n\r\n") rescue nil
 
     shutdown rescue nil
     req_res.shutdown rescue nil
@@ -59,16 +60,16 @@ module Yahns::HttpResponse # :nodoc:
   # returns nil if completely done
   def proxy_response_start(res, tip, kcar, req_res)
     status, headers = res
-    si = status.to_i
-    status = CODES[si] || status
+    code = status.to_i
+    msg = Rack::Utils::HTTP_STATUS_CODES[code]
     env = @hs.env
-    have_body = !Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(si) &&
+    have_body = !Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(code) &&
                 env[REQUEST_METHOD] != HEAD
     flags = MSG_DONTWAIT
     alive = @hs.next? && self.class.persistent_connections
     response_headers = env['yahns.proxy_pass.response_headers']
 
-    res = "HTTP/1.1 #{status}\r\n"
+    res = "HTTP/1.1 #{msg ? %Q(#{code} #{msg}) : status}\r\n"
     headers.each do |key,value| # n.b.: headers is an Array of 2-element Arrays
       case key
       when /\A(?:Connection|Keep-Alive)\z/i