Skip to content

Commit

Permalink
Fix Resouce: append found method to returned allowed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Mar 12, 2016
1 parent 437efda commit 02187ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,8 @@ CHANGES
- Fix ResourceAdapter: dont add method to allowed if resource is not
match #826

- Fix Resouce: append found method to returned allowed methods

0.21.1 (02-10-2016)
-------------------

Expand Down
3 changes: 1 addition & 2 deletions aiohttp/web_urldispatcher.py
Expand Up @@ -258,11 +258,10 @@ def resolve(self, method, path):

for route in self._routes:
route_method = route.method
allowed_methods.add(route_method)

if route_method == method or route_method == hdrs.METH_ANY:
return UrlMappingMatchInfo(match_dict, route), allowed_methods

allowed_methods.add(route_method)
else:
return None, allowed_methods

Expand Down
8 changes: 8 additions & 0 deletions tests/test_urldispatch.py
Expand Up @@ -904,3 +904,11 @@ def test_405_for_resource_adapter(self):
ret = self.loop.run_until_complete(
resource.resolve('POST', '/st/abc.py'))
self.assertEqual((None, {'GET'}), ret)

def test_check_allowed_method_for_found_resource(self):
handler = self.make_handler()
resource = self.router.add_resource('/')
resource.add_route('GET', handler)
ret = self.loop.run_until_complete(resource.resolve('GET', '/'))
self.assertIsNotNone(ret[0])
self.assertEqual({'GET'}, ret[1])

0 comments on commit 02187ee

Please sign in to comment.