diff options
author | Eric Wong <e@80x24.org> | 2015-06-30 00:45:38 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-06-30 02:46:02 +0000 |
commit | baaebed4d7c50a3f14fbada767bada6fc2f0c8b5 (patch) | |
tree | dd3838815bfd320f65244a19ae15af14a5dbdc73 /lib/yahns/proxy_http_response.rb | |
parent | dbb0db4cc9ba99e975d7a61e99756c38d6f68a79 (diff) | |
download | yahns-baaebed4d7c50a3f14fbada767bada6fc2f0c8b5.tar.gz |
Rack::Utils::HTTP_STATUS_CODES may be altered by the underlying application, allow changes to that to be reflected in our responses and do not rely on the Unicorn::HttpResponse::CODES hash which will probably go away soon.
Diffstat (limited to 'lib/yahns/proxy_http_response.rb')
-rw-r--r-- | lib/yahns/proxy_http_response.rb | 11 |
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 |