Skip to content

Internal server error while requesting static route #840

@31z4

Description

@31z4

Long story short

Having a simple app with just a single static route I'm getting a weird response on GET /.

Expected behaviour

404 Not Found is returned on GET /.

Actual behaviour

200 OK is returned but body says it's 500 Internal Server Error

Steps to reproduce

Application source code

from aiohttp import web

if __name__ == '__main__':
    app = web.Application()
    app.router.add_static('/', '.')
    web.run_app(app)

Request and response

$ curl -v http://$(docker-machine ip default):8080/
*   Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8080 (#0)
> GET / HTTP/1.1
> Host: 192.168.99.100:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< CONTENT-TYPE: application/octet-stream
< LAST-MODIFIED: Wed, 23 Mar 2016 19:10:04 GMT
< CONTENT-LENGTH: 4096
< DATE: Wed, 23 Mar 2016 19:23:45 GMT
< SERVER: Python/3.5 aiohttp/0.21.5
< 
HTTP/1.1 500 Internal Server Error
CONTENT-TYPE: text/html; charset=utf-8
CONTENT-LENGTH: 170
CONNECTION: close
DATE: Wed, 23 Mar 2016 19:23:45 GMT
SERVER: Python/3.5 aiohttp/0.21.5


<html>
  <head>
    <title>500 Internal Server Error</title>
  </head>
  <body>
    <h1>500 Internal Server Error</h1>
    Server got itself in trouble
  </body>
* transfer closed with 3736 bytes remaining to read
* Closing connection 0
curl: (18) transfer closed with 3736 bytes remaining to read
</html>

Traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/server.py", line 266, in start
    yield from self.handle_request(message, payload)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 90, in handle_request
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_urldispatcher.py", line 595, in handle
    with filepath.open('rb') as f:
  File "/usr/local/lib/python3.5/pathlib.py", line 1136, in open
    opener=self._opener)
IsADirectoryError: [Errno 21] Is a directory: '/usr/src/app'

Your environment

Linux 1ef7cdcd22ed 4.1.19-boot2docker #1 SMP Mon Mar 7 17:44:33 UTC 2016 x86_64 GNU/Linux
Python 3.5.1
aiohttp==0.21.5
chardet==2.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions