Sha256: ff9608320d508b6ecd548bfd501ccf91ffb660063fe26dd97866d38d1d929bfc
Contents?: true
Size: 950 Bytes
Versions: 3
Compression:
Stored size: 950 Bytes
Contents
# -*- encoding: binary -*- require 'time' require 'rainbows' module Rainbows class HttpResponse < ::Unicorn::HttpResponse def self.write(socket, rack_response, out = []) status, headers, body = rack_response if Array === out status = CODES[status.to_i] || status headers.each do |key, value| next if %r{\AX-Rainbows-}i =~ key next if SKIP.include?(key.downcase) if value =~ /\n/ out.concat(value.split(/\n/).map! { |v| "#{key}: #{v}\r\n" }) else out << "#{key}: #{value}\r\n" end end socket.write("HTTP/1.1 #{status}\r\n" \ "Date: #{Time.now.httpdate}\r\n" \ "Status: #{status}\r\n" \ "#{out.join('')}\r\n") end body.each { |chunk| socket.write(chunk) } ensure body.respond_to?(:close) and body.close rescue nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rainbows-0.5.0 | lib/rainbows/http_response.rb |
rainbows-0.4.0 | lib/rainbows/http_response.rb |
rainbows-0.3.0 | lib/rainbows/http_response.rb |