summary refs log tree commit
diff options
context:
space:
mode:
authorBraulio Martinez <braulio@paragon-labs.com>2017-01-24 18:04:30 -0300
committerBraulio Martinez <braulio@paragon-labs.com>2017-01-24 18:04:30 -0300
commitb2e8b0fab8b49030a342074227820f3f6cc0d644 (patch)
treecea6f92cc8dbb998bdd9aba8e2dbb0a7c388ae53
parentbfd4c155a9ba2fb1fcee8daab433fbdef582cce2 (diff)
downloadrack-b2e8b0fab8b49030a342074227820f3f6cc0d644.tar.gz
Update bytesize usage after its removal from rack utils
-rw-r--r--lib/rack/file.rb2
-rw-r--r--test/spec_file.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/rack/file.rb b/lib/rack/file.rb
index 0a257b3d..09eb0afb 100644
--- a/lib/rack/file.rb
+++ b/lib/rack/file.rb
@@ -158,7 +158,7 @@ module Rack
 
     def filesize path
       # If response_body is present, use its size.
-      return Rack::Utils.bytesize(response_body) if response_body
+      return response_body.bytesize if response_body
 
       #   We check via File::size? whether this file provides size info
       #   via stat (e.g. /proc files often don't), otherwise we have to
diff --git a/test/spec_file.rb b/test/spec_file.rb
index 38e3c92e..48c0ab90 100644
--- a/test/spec_file.rb
+++ b/test/spec_file.rb
@@ -248,4 +248,17 @@ describe Rack::File do
     res.body.must_be :empty?
   end
 
+  class MyFile < Rack::File
+    def response_body
+      "hello world"
+    end
+  end
+
+  it "behaves gracefully if response_body is present" do
+    file = Rack::Lint.new MyFile.new(DOCROOT)
+    res  = Rack::MockRequest.new(file).get("/cgi/test")
+
+    res.must_be :ok?
+  end
+
 end