about summary refs log tree commit
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-11-23 12:51:38 -0800
committerEric Wong <normalperson@yhbt.net>2010-11-23 12:51:54 -0800
commite232eef239952d94220d87ae9be5b27690fe6699 (patch)
tree9ac421eab03cf39852abf6ef372d3e3fdb03004a /lib
parente83353f18f4813365581be81672eaf2e3c2e3d3a (diff)
downloadmetropolis-e232eef239952d94220d87ae9be5b27690fe6699.tar.gz
add generic Rack read/write test
This fixes 404s on HEAD requests which do not return a body.
Diffstat (limited to 'lib')
-rw-r--r--lib/metropolis/common.rb4
-rw-r--r--lib/metropolis/tc/hdb.rb2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/metropolis/common.rb b/lib/metropolis/common.rb
index b86102d..3bfbf77 100644
--- a/lib/metropolis/common.rb
+++ b/lib/metropolis/common.rb
@@ -2,8 +2,8 @@
 module Metropolis::Common
   include Rack::Utils # unescape
 
-  def r(code)
-    body = "#{HTTP_STATUS_CODES[code]}\n"
+  def r(code, body = nil)
+    body ||= "#{HTTP_STATUS_CODES[code]}\n"
     [ code,
       { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/plain' },
       [ body ] ]
diff --git a/lib/metropolis/tc/hdb.rb b/lib/metropolis/tc/hdb.rb
index 11bc65d..eed46ef 100644
--- a/lib/metropolis/tc/hdb.rb
+++ b/lib/metropolis/tc/hdb.rb
@@ -109,7 +109,7 @@ module Metropolis::TC::HDB
 
   def head(key)
     size = reader(key) { |hdb| hdb.vsiz(key) or ex!(:vsiz, hdb) }
-    0 > size and return r(404)
+    0 > size and return r(404, "")
     [ 200, { 'Content-Length' => size.to_s }.merge!(@headers), [] ]
   end