Skip to content

Commit 06f2451

Browse files
authored
Merge pull request #252 from jlahtinen/master
Remove usage of Rack::Utils.bytesize
2 parents a965a33 + 8cba783 commit 06f2451

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/main/ruby/jruby/rack/error_app.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ def serve(code, path, env)
7070
headers = { 'Last-Modified' => last_modified }
7171
DEFAULT_HEADERS.each { |field, content| headers[field] = content }
7272
ext = File.extname(path)
73+
size = File.size?(path)
7374
mime = ::Rack::Mime.mime_type(ext, DEFAULT_MIME) if defined?(::Rack::Mime)
7475
mime = 'text/html' if ! mime && ( ext == '.html' || ext == '.htm' )
7576
headers['Content-Type'] = mime if mime
7677

77-
body = env['REQUEST_METHOD'] == 'HEAD' ? [] : FileBody.new(path, size = File.size?(path))
78+
body = env['REQUEST_METHOD'] == 'HEAD' ? [] : FileBody.new(path, size)
7879
response = [ code, headers, body ]
7980

80-
size ||= ::Rack::Utils.bytesize(File.read(path)) if defined?(::Rack::Utils.bytesize)
81-
8281
response[1]['Content-Length'] = size.to_s if size
8382
response
8483
end
@@ -169,4 +168,4 @@ def http_accept?(env, mime)
169168

170169
end
171170
end
172-
end
171+
end

src/main/ruby/jruby/rack/error_app/show_status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def call(env)
2727
detail = detail = env["rack.showstatus.detail"] || message
2828

2929
body = @template.result(binding)
30-
size = ::Rack::Utils.bytesize(body)
30+
size = body.bytesize
3131
[status, headers.merge('Content-Type' => "text/html", 'Content-Length' => size.to_s), [body]]
3232
else
3333
[status, headers, body]

0 commit comments

Comments
 (0)