Skip to content

Commit

Permalink
Fix do_not_route_options! handling: do not respond to OPTIONS if di…
Browse files Browse the repository at this point in the history
…sabled!
  • Loading branch information
jf committed Aug 23, 2015
1 parent b480fed commit 3f3c0ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [#1109](https://github.com/ruby-grape/grape/pull/1109): Memoize Virtus attribute and fix memory leak - [@marshall-lee](https://github.com/marshall-lee).
* [#1101](https://github.com/intridea/grape/pull/1101): Fix: Incorrect media-type `Accept` header now correctly returns 406 with `strict: true` - [@elliotlarson](https://github.com/elliotlarson).
* [#1108](https://github.com/ruby-grape/grape/pull/1039): Raise a warning when `desc` is called with options hash and block - [@rngtng](https://github.com/rngtng).
* [#1119](https://github.com/ruby-grape/grape/pull/1119): Fix `do_not_route_options!` handling: do not respond to OPTIONS if disabled! - [@jf](https://github.com/jf).

0.13.0 (8/10/2015)
==================
Expand Down
14 changes: 7 additions & 7 deletions lib/grape/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ def add_head_not_allowed_methods_and_options_methods
unless self.class.namespace_inheritable(:do_not_route_head)
allowed_methods |= [Grape::Http::Headers::HEAD] if allowed_methods.include?(Grape::Http::Headers::GET)
end
allowed_methods |= [Grape::Http::Headers::OPTIONS] unless self.class.namespace_inheritable(:do_not_route_options)

allow_header = allowed_methods.join(', ')

allow_header = ([Grape::Http::Headers::OPTIONS] | allowed_methods).join(', ')
unless self.class.namespace_inheritable(:do_not_route_options)
unless allowed_methods.include?(Grape::Http::Headers::OPTIONS)
self.class.options(path, {}) do
header 'Allow', allow_header
status 204
''
end
self.class.options(path, {}) do
header 'Allow', allow_header
status 204
''
end
end

Expand Down

0 comments on commit 3f3c0ba

Please sign in to comment.