File tree Expand file tree Collapse file tree 2 files changed +6
-38
lines changed
Expand file tree Collapse file tree 2 files changed +6
-38
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def call(env)
4646
4747 code = response_code ( env )
4848
49- return respond ( code ) if ! root || ! accept_html ?( env )
49+ return respond ( code ) if !root || !accepts_html ?( env )
5050
5151 # TODO support custom JSON/XML 5xx and better HTTP_ACCEPT matching
5252 # NOTE: code == 503 ... we're try 503.html and fallback to 500.html
@@ -152,41 +152,9 @@ def expand_path(path, root = self.root)
152152 end
153153 end
154154
155- begin
156- require 'rack/utils'
157- Utils = ::Rack ::Utils
158-
159- if '' . respond_to? ( :bytesize ) # Ruby >= 1.9
160- def Utils . bytesize ( string ) ; string . bytesize end
161- else
162- def Utils . bytesize ( string ) ; string . size end
163- end unless defined? Utils . bytesize
164-
165- require 'rack/mime'
166- rescue LoadError ; end
167-
168- if defined? Utils . best_q_match
169-
170- def accepts_html? ( env )
171- Utils . best_q_match ( env [ 'HTTP_ACCEPT' ] , %w[ text/html ] )
172- rescue
173- http_accept? ( env , 'text/html' )
174- end
175-
176- else
177-
178- def accepts_html? ( env )
179- http_accept? ( env , 'text/html' ) || http_accept? ( env , '*/*' )
180- end
181-
155+ def accepts_html? ( env )
156+ ::Rack ::Utils . best_q_match ( env [ 'HTTP_ACCEPT' ] , %w[ text/html ] )
182157 end
183- alias accept_html? accepts_html? # JRuby-Rack 1.1 compatibility
184-
185- def http_accept? ( env , mime )
186- http_accept = env [ 'HTTP_ACCEPT' ] . to_s
187- http_accept . empty? ? nil : !! http_accept . index ( mime )
188- end
189-
190158 end
191159 end
192160end
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ def initialize(app)
1515
1616 def call ( env )
1717 status , headers , body = @app . call ( env )
18- headers = Utils ::HeaderHash . new ( headers )
18+ headers = :: Rack :: Utils ::HeaderHash . new ( headers )
1919 empty = headers [ 'Content-Length' ] . to_i <= 0
2020
2121 detail = env [ 'rack.showstatus.detail' ]
2222 # client or server error, or explicit message
2323 if ( status . to_i >= 400 && empty ) || detail
2424 # required erb template variables (captured with binding) :
2525 request = req = ::Rack ::Request . new ( env ) ; request && req # avoid un-used warning
26- message = Utils ::HTTP_STATUS_CODES [ status . to_i ] || status . to_s
26+ message = :: Rack :: Utils ::HTTP_STATUS_CODES [ status . to_i ] || status . to_s
2727 detail = detail . nil? ? message : detail # false for no detail
2828
2929 body = @template . result ( binding )
@@ -36,7 +36,7 @@ def call(env)
3636
3737 # @private
3838 def h ( obj )
39- obj . is_a? ( String ) ? Utils . escape_html ( obj ) : Utils . escape_html ( obj . inspect )
39+ obj . is_a? ( String ) ? :: Rack :: Utils . escape_html ( obj ) : :: Rack :: Utils . escape_html ( obj . inspect )
4040 end
4141
4242 # :stopdoc:
You can’t perform that action at this time.
0 commit comments