Skip to content

Commit cd91e74

Browse files
committed
re-arrange JRuby::Rack::ErrorApp internals
1 parent 0f83d77 commit cd91e74

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ def serve(code, path, env)
7575
body = env['REQUEST_METHOD'] == 'HEAD' ? [] : FileBody.new(path, size = File.size?(path))
7676
response = [ code, headers, body ]
7777

78-
size ||= ::Rack::Utils.bytesize(File.read(path)) if defined?(::Rack::Utils)
78+
size ||= ::Rack::Utils.bytesize(File.read(path)) if defined?(::Rack::Utils.bytesize)
7979

8080
response[1]['Content-Length'] = size.to_s if size
8181
response
8282
end
8383

84-
private
84+
protected
8585

8686
def accept_html?(env)
8787
http_accept = env['HTTP_ACCEPT'].to_s
@@ -112,15 +112,6 @@ def respond(status = nil, body = nil, headers = DEFAULT_HEADERS)
112112
[ status, headers, body ? [ body ] : [] ]
113113
end
114114

115-
def expand_path(path, root = self.root)
116-
exp_path = File.join(root, path)
117-
begin
118-
return exp_path if File.file?(exp_path) && File.readable?(exp_path)
119-
rescue SystemCallError
120-
nil
121-
end
122-
end
123-
124115
class FileBody
125116

126117
attr_reader :path, :size
@@ -145,14 +136,22 @@ def each
145136

146137
end
147138

148-
def self.silent_require(feature)
149-
require feature
150-
rescue LoadError
151-
nil
139+
private
140+
141+
def expand_path(path, root = self.root)
142+
exp_path = File.join(root, path)
143+
begin
144+
return exp_path if File.file?(exp_path) && File.readable?(exp_path)
145+
rescue SystemCallError
146+
nil
147+
end
152148
end
153149

154-
silent_require 'rack/utils'
155-
silent_require 'rack/mime'
150+
begin
151+
require 'rack/utils'
152+
require 'rack/mime'
153+
rescue LoadError
154+
end
156155

157156
end
158157
end

0 commit comments

Comments
 (0)