about summary refs log tree commit homepage
path: root/lib/rainbows/http_response.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-08 23:21:18 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-08 23:21:18 +0000
commit9abb447a573751b87e26ce35f4f05d58290f4c41 (patch)
tree1adb0dac9acd99c9add0880751c7e022003776ef /lib/rainbows/http_response.rb
parent235985c6c4b37ed9a170c38052db3ef0772b1527 (diff)
downloadrainbows-9abb447a573751b87e26ce35f4f05d58290f4c41.tar.gz
Cramp monkey patches Rainbows internals for WebSockets
support and we forgot about it.  Add a new integration
test to ensure this continues to work in the future
(and force us to update the test for newer Cramp).
Diffstat (limited to 'lib/rainbows/http_response.rb')
-rw-r--r--lib/rainbows/http_response.rb48
1 files changed, 7 insertions, 41 deletions
diff --git a/lib/rainbows/http_response.rb b/lib/rainbows/http_response.rb
index 677b5a7..cf17aa1 100644
--- a/lib/rainbows/http_response.rb
+++ b/lib/rainbows/http_response.rb
@@ -1,44 +1,10 @@
 # -*- encoding: binary -*-
-require 'time' # for Time#httpdate
-
-# :stopdoc:
-module Rainbows::HttpResponse
-
-  CODES = Unicorn::HttpResponse::CODES
-
-  def response_header(response, out)
-    status, headers = response
-    status = CODES[status.to_i] || status
-
-    headers.each do |key, value|
-      next if %r{\A(?:X-Rainbows-|Connection\z|Date\z|Status\z)}i =~ key
-      if value =~ /\n/
-        # avoiding blank, key-only cookies with /\n+/
-        out.concat(value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" })
-      else
-        out << "#{key}: #{value}\r\n"
-      end
-    end
-
-    "HTTP/1.1 #{status}\r\n" \
-    "Date: #{Time.now.httpdate}\r\n" \
-    "Status: #{status}\r\n" \
-    "#{out.join('')}\r\n"
-  end
-
-  def write_header(socket, response, out)
-    out and socket.write(response_header(response, out))
-  end
-
-  def write_response(socket, response, out)
-    write_header(socket, response, out)
-    write_body(socket, response[2])
-  end
-
-  # called after forking
-  def self.setup(klass)
-    require('rainbows/http_response/body') and
-      klass.__send__(:include, Rainbows::HttpResponse::Body)
+# deprecated, use Rainbows::Response instead
+# Cramp 0.11 relies on this
+# :enddoc:
+class Rainbows::HttpResponse
+  class << self
+    include Rainbows::Response
+    alias write write_response
   end
 end
-# :startdoc: