Skip to content

Commit

Permalink
Don't create a new resource with allow_head=True (#2585)
Browse files Browse the repository at this point in the history
* Don't create a new resource with allow_head=True

* Add missing changes
  • Loading branch information
asvetlov authored Dec 4, 2017
1 parent 3ed3c9c commit e0bb501
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES/2585.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not create a new resource on `router.add_get(..., allow_head=True)`
10 changes: 3 additions & 7 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,10 @@ def add_get(self, path, handler, *, name=None, allow_head=True, **kwargs):
Shortcut for add_route with method GET, if allow_head is true another
route is added allowing head requests to the same endpoint
"""
resource = self.add_resource(path, name=name)
if allow_head:
# it name is not None append -head to avoid it conflicting with
# the GET route below
head_name = name and '{}-head'.format(name)
self.add_route(hdrs.METH_HEAD, path, handler,
name=head_name, **kwargs)
return self.add_route(hdrs.METH_GET, path, handler, name=name,
**kwargs)
resource.add_route(hdrs.METH_HEAD, handler, **kwargs)
return resource.add_route(hdrs.METH_GET, handler, **kwargs)

def add_post(self, path, handler, **kwargs):
"""
Expand Down

0 comments on commit e0bb501

Please sign in to comment.