watcher: do not require Rack::Head for HEAD response
authorEric Wong <normalperson@yhbt.net>
Mon, 18 Jun 2012 20:50:06 +0000 (18 13:50 -0700)
committerEric Wong <normalperson@yhbt.net>
Mon, 18 Jun 2012 20:50:06 +0000 (18 13:50 -0700)
Rack webservers are not guaranteed to include Rack::Head in the
middleware stack.  Watcher is a standalone app, so it cannot
rely on a framework which automatically includes Rack::Head.

lib/raindrops/watcher.rb

index 5493374..43c30ef 100644 (file)
@@ -143,8 +143,12 @@ class Raindrops::Watcher
   def call(env)
     @start.synchronize { @thr ||= aggregator_thread(env["rack.logger"]) }
     case env["REQUEST_METHOD"]
-    when "HEAD", "GET"
+    when "GET"
       get env
+    when "HEAD"
+      r = get(env)
+      r[2] = []
+      r
     when "POST"
       post env
     else