Skip to content

Commit

Permalink
Merge pull request #493 from morgan-del/url-parsing-bug
Browse files Browse the repository at this point in the history
Fix #489 : properly parse URL's path
  • Loading branch information
asvetlov committed Sep 4, 2015
2 parents 5896dc0 + 430af0a commit 0e8fe54
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiohttp/web_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def path_qs(self):

@reify
def _splitted_path(self):
return urlsplit(self._path_qs)
url = '{}://{}{}'.format(self.scheme, self.host, self._path_qs)
return urlsplit(url)

@property
def raw_path(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setUp(self):
def tearDown(self):
self.loop.close()

@unittest.skip('moved to test_web_functional')
def test_handler_returns_not_response(self):
app = web.Application(loop=self.loop)

Expand Down
14 changes: 14 additions & 0 deletions tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ def go():

self.loop.run_until_complete(go())

def test_handler_returns_not_response(self):

@asyncio.coroutine
def handler(request):
return 'abc'

@asyncio.coroutine
def go():
_, _, url = yield from self.create_server('GET', '/', handler)
resp = yield from request('GET', url, loop=self.loop)
self.assertEqual(500, resp.status)

self.loop.run_until_complete(go())

def test_post_form(self):

@asyncio.coroutine
Expand Down
4 changes: 4 additions & 0 deletions tests/test_web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def test_ctor(self):
self.assertIs(self.transport, req.transport)
self.assertTrue(req.keep_alive)

def test_doubleslashes(self):
req = self.make_request('GET', '//foo/')
self.assertEqual('//foo/', req.path)

def test_POST(self):
req = self.make_request('POST', '/')
with self.assertRaises(RuntimeError):
Expand Down

0 comments on commit 0e8fe54

Please sign in to comment.