diff options
Diffstat (limited to 'lib/unicorn')
-rw-r--r-- | lib/unicorn/http_response.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index 5602a43..0835820 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -33,9 +33,7 @@ module Unicorn SKIP = { 'connection' => true, 'date' => true, 'status' => true }.freeze OUT = [] # :nodoc - # writes the rack_response to socket as an HTTP response - def self.write(socket, rack_response) - status, headers, body = rack_response + def self.write_header(socket, status, headers) status = CODES[status.to_i] || status OUT.clear @@ -59,6 +57,13 @@ module Unicorn "Status: #{status}\r\n" \ "Connection: close\r\n" \ "#{OUT.join(Z)}\r\n") + + end + + # writes the rack_response to socket as an HTTP response + def self.write(socket, rack_response, have_header = true) + status, headers, body = rack_response + write_header(socket, status, headers) if have_header body.each { |chunk| socket.write(chunk) } socket.close # flushes and uncorks the socket immediately ensure |