diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-03-13 20:30:04 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-03-13 20:30:04 +0000 |
commit | b224beaa20981b38ce1290b09b92d77dca360bed (patch) | |
tree | d5342e3f6dd06e2cdfc6e34bdc651ec60a3380d2 | |
parent | 07447600a238850ee59bdccd72de470931fbffab (diff) | |
download | omgf-b224beaa20981b38ce1290b09b92d77dca360bed.tar.gz |
fix backwards compatiblity with HEAD response headers
Hysterically, we used "X-Url-" instead of "X-URL-", so we must maintain that compatibility to case-sensitive clients (such as our lazy awk script inside the hyst bash script). We exist only for hysterical raisins, after all.
-rw-r--r-- | lib/omgf/hysterical_raisins.rb | 2 | ||||
-rw-r--r-- | test/test_hyst.rb | 14 | ||||
-rw-r--r-- | test/test_hysterical_raisins.rb | 8 |
3 files changed, 19 insertions, 5 deletions
diff --git a/lib/omgf/hysterical_raisins.rb b/lib/omgf/hysterical_raisins.rb index 41c0f6c..f48e9fe 100644 --- a/lib/omgf/hysterical_raisins.rb +++ b/lib/omgf/hysterical_raisins.rb @@ -123,7 +123,7 @@ class OMGF::HystericalRaisins fn = filename(h, query(env)) || key h["Content-Type"] = key_mime_type(fn) unless reproxy?(env, key, h, uris[0].to_s) - uris.each_with_index { |uri,i| h["X-URL-#{i}"] = uri.to_s } + uris.each_with_index { |uri,i| h["X-Url-#{i}"] = uri.to_s } end [ 200, h, [] ] end diff --git a/test/test_hyst.rb b/test/test_hyst.rb index b29e2d8..a4331c0 100644 --- a/test/test_hyst.rb +++ b/test/test_hyst.rb @@ -45,6 +45,20 @@ class TestHystScript < Test::Unit::TestCase assert_equal "HI\n", out assert_equal "HI\n", `#@hyst cat foo` + # ensure stat returns needed output + lines = `#@hyst stat foo`.split(/\n/) + + key = lines.grep(/^Key: /) + assert_equal 1, key.size, lines + assert_equal "Key: foo", key[0] + + size = lines.grep(/^Size: /) + assert_equal 1, size.size, lines + assert_equal "Size: 3", size[0] + + urls = lines.grep(/^URL/) + assert_match(/^URL-0: /, urls[0], urls.inspect) + # /dev/null optimization out = `echo NULL | #@hyst tee bar >/dev/null` assert_equal 0, $? diff --git a/test/test_hysterical_raisins.rb b/test/test_hysterical_raisins.rb index e97a900..689b77d 100644 --- a/test/test_hysterical_raisins.rb +++ b/test/test_hysterical_raisins.rb @@ -184,18 +184,18 @@ class TestHystericalRaisins < Test::Unit::TestCase assert_equal 0, @err.string.size, @err.string assert_equal 200, resp.status, resp.inspect assert_equal "4", resp["Content-Length"] - assert_equal "BLAH", open(resp["X-URL-0"]).read + assert_equal "BLAH", open(resp["X-Url-0"]).read # wait for replication if ENV["EXPENSIVE"] 50.times do resp = @req.head("/testdom/key", @opts) assert_equal 200, resp.status, resp.inspect - resp["X-URL-1"] and break + resp["X-Url-1"] and break sleep 0.5 end - assert_kind_of String, resp["X-URL-1"], resp.inspect - assert_equal "BLAH", open(resp["X-URL-1"]).read + assert_kind_of String, resp["X-Url-1"], resp.inspect + assert_equal "BLAH", open(resp["X-Url-1"]).read # Location should not be in X-Alt-Location, too resp = @req.get("/testdom/key", @opts) |