diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-09 08:30:15 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-09 08:30:15 +0000 |
commit | e1c10949271a9cd3cbad86d05ce0436f2e79bc65 (patch) | |
tree | 8cabace4d7e7ecda05571f843d694381bce4971e /lib/rainbows | |
parent | 9abb447a573751b87e26ce35f4f05d58290f4c41 (diff) | |
download | rainbows-e1c10949271a9cd3cbad86d05ce0436f2e79bc65.tar.gz |
Cramp needs to override our normal header sending for (old) WebSockets connections.
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/http_response.rb | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/rainbows/http_response.rb b/lib/rainbows/http_response.rb index cf17aa1..40a7330 100644 --- a/lib/rainbows/http_response.rb +++ b/lib/rainbows/http_response.rb @@ -1,10 +1,27 @@ # -*- encoding: binary -*- # deprecated, use Rainbows::Response instead -# Cramp 0.11 relies on this +# Cramp 0.11 relies on this, and is only activated by Cramp # :enddoc: -class Rainbows::HttpResponse - class << self - include Rainbows::Response - alias write write_response +if defined?(Cramp) && defined?(Rainbows::EventMachine::Client) + class Rainbows::HttpResponse + class << self + include Rainbows::Response + alias write write_response + end + end + + module Rainbows::EventMachine::CrampSocket + def write_header(_, response, out) + if websocket? + write web_socket_upgrade_data + web_socket_handshake! + out = nil # disable response headers + end + super(self, response, out) + end + end + + class Rainbows::EventMachine::Client + include Rainbows::EventMachine::CrampSocket end end |