about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-03 23:21:14 +0000
committerEric Wong <e@80x24.org>2016-07-05 20:38:01 +0000
commit97ef2a9c592fbdb756aa6a73e2e6c90b6b3cda18 (patch)
tree41759197b5af676d5ad101505bc9d026812fe868
parent405435825e90c5f79209946ecd8fc842519b42ba (diff)
downloadyahns-97ef2a9c592fbdb756aa6a73e2e6c90b6b3cda18.tar.gz
This is mainly to benefit curl(1) users who forget to use '-f'
to show failures.  Not sure if I want to keep this change, it
seems like bloat; but Rack::ShowStatus pages are totally
overkill...
-rw-r--r--extras/autoindex.rb5
-rw-r--r--extras/try_gzip_static.rb5
-rw-r--r--test/test_extras_try_gzip_static.rb9
3 files changed, 9 insertions, 10 deletions
diff --git a/extras/autoindex.rb b/extras/autoindex.rb
index 4deb3ef..238edd9 100644
--- a/extras/autoindex.rb
+++ b/extras/autoindex.rb
@@ -168,8 +168,9 @@ class Autoindex
     if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(code)
       [ code, {}, [] ]
     else
-      h = { 'Content-Type' => 'text/plain', 'Content-Length' => '0' }
-      [ code, h, [] ]
+      msg = "#{code} #{Rack::Utils::HTTP_STATUS_CODES[code.to_i]}\n"
+      h = { 'Content-Type' => 'text/plain', 'Content-Length' => msg.size.to_s }
+      [ code, h, [ msg ] ]
     end
   end
 
diff --git a/extras/try_gzip_static.rb b/extras/try_gzip_static.rb
index ed561cb..d412589 100644
--- a/extras/try_gzip_static.rb
+++ b/extras/try_gzip_static.rb
@@ -216,8 +216,9 @@ class TryGzipStatic
     if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(code)
       [ code, {}, [] ]
     else
-      h = { 'Content-Type' => 'text/plain', 'Content-Length' => '0' }
-      [ code, h, [] ]
+      msg = "#{code} #{Rack::Utils::HTTP_STATUS_CODES[code.to_i]}\n"
+      h = { 'Content-Type' => 'text/plain', 'Content-Length' => msg.size.to_s }
+      [ code, h, [ msg ] ]
     end
   end
 end
diff --git a/test/test_extras_try_gzip_static.rb b/test/test_extras_try_gzip_static.rb
index 60129df..b6d5943 100644
--- a/test/test_extras_try_gzip_static.rb
+++ b/test/test_extras_try_gzip_static.rb
@@ -125,11 +125,10 @@ class TestExtrasTryGzipStatic < Testcase
 
         req = "#{m} /COPYING HTTP/1.0\r\n" \
               "Range: bytes=66666666-\r\nAccept-Encoding: gzip"
-        body = check.call(req) do |head|
+        check.call(req) do |head|
           assert_match %r{^Content-Range: bytes \*/#{st.size}\r\n}, head
           assert_match %r{\AHTTP/1\.1 416 }, head
         end
-        assert_nil body
       end
     end
 
@@ -181,15 +180,13 @@ class TestExtrasTryGzipStatic < Testcase
     Timeout.timeout(30) do # 404
       %w(GET HEAD).each do |m|
         req = "#{m} /cp-ing HTTP/1.0\r\nAccept-Encoding: gzip"
-        body = check.call(req) do |head|
+        check.call(req) do |head|
           assert_match %r{HTTP/1\.1 404 }, head
         end
-        assert_nil body
       end
-      body = check.call("FOO /COPYING HTTP/1.0") do |head|
+      check.call("FOO /COPYING HTTP/1.0") do |head|
         assert_match %r{HTTP/1\.1 405 }, head
       end
-      assert_nil body
     end
 
     Net::HTTP.start(host, port) do |http|