Skip to content

Commit e31fa39

Browse files
author
Jonathan Garay
committed
* Fix: formatter try to evaluate the headers sym_links hash keys as string
1 parent 8ee8481 commit e31fa39

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/grape/middleware/formatter.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def default_options
1313
:parsers => {}
1414
}
1515
end
16-
16+
1717
def headers
18-
env.dup.inject({}){|h,(k,v)| h[k.downcase[5..-1]] = v if k.downcase.start_with?('http_'); h}
18+
env.dup.inject({}){|h,(k,v)| h[k.downcase[5..-1]] = v if k.downcase.to_s.start_with?('http_'); h}
1919
end
20-
20+
2121
def before
2222
fmt = format_from_extension || options[:format] || format_from_header || options[:default_format]
2323
if content_types.key?(fmt)
@@ -39,7 +39,7 @@ def before
3939
throw :error, :status => 406, :message => 'The requested format is not supported.'
4040
end
4141
end
42-
42+
4343
def format_from_extension
4444
parts = request.path.split('.')
4545
extension = parts.last.to_sym
@@ -49,7 +49,7 @@ def format_from_extension
4949
end
5050
nil
5151
end
52-
52+
5353
def format_from_header
5454
mime_array.each do |t|
5555
if mime_types.key?(t)
@@ -58,15 +58,15 @@ def format_from_header
5858
end
5959
nil
6060
end
61-
61+
6262
def mime_array
6363
accept = headers['accept'] or return []
6464

6565
accept.gsub(/\b/,'').scan(%r((\w+/[\w+.-]+)(?:(?:;[^,]*?)?;\s*q=([\d.]+))?)).sort_by { |_, q| -q.to_f }.map {|mime, _|
6666
mime.sub(%r(vnd\.[^+]+\+), '')
6767
}
6868
end
69-
69+
7070
def after
7171
status, headers, bodies = *@app_response
7272
formatter = formatter_for env['api.format']

0 commit comments

Comments
 (0)