Fix Invalid Path Resource error

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-08-30 12:33:29 +02:00
parent 6e5633a460
commit c9a9e90a7e
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -181,7 +181,10 @@ async def get_field(request):
except KeyError: except KeyError:
response = web.HTTPNotFound() response = web.HTTPNotFound()
else: else:
content = await connection.get(field) try:
content = await connection.get(field)
except ValueError:
return web.Response(status=400, reason="Invalid Resource Path")
if isinstance(content, StreamReader): if isinstance(content, StreamReader):
response = web.StreamResponse(status=200, reason="OK") response = web.StreamResponse(status=200, reason="OK")
@@ -10,6 +10,6 @@ Feature: Fail to retrieve an invalid resource for a handler in Kapow! server.
| method | url_pattern | | method | url_pattern |
| GET | /listRootDir | | GET | /listRootDir |
When I send a request to the testing route "/listRootDir" When I send a request to the testing route "/listRootDir"
And I get the resource "invented/path" And I get the resource "/invented/path"
Then I get 400 as response code Then I get 400 as response code
And I get "Invalid Resource Path" as response reason phrase And I get "Invalid Resource Path" as response reason phrase