AttributeError: 'NoneType' object has no attribute 'handle_expect_header' #340
Closed
Description
Hello,
Hang on to your hats, this is a long bug report ;)
When running this code (modified from one of the examples):
#!/usr/bin/env python3
import asyncio
from aiohttp.web import Application, Response, StreamResponse
def simple(request):
return Response(body=b'Simple answer')
@asyncio.coroutine
def init(loop):
app = Application(loop=loop)
app.router.add_route('POST', '/simplepost', simple)
app.router.add_route('GET', '/simpleget', simple)
handler = app.make_handler()
srv = yield from loop.create_server(handler, '127.0.0.1', 8080)
print("Server started at http://127.0.0.1:8080")
return srv, handler
loop = asyncio.get_event_loop()
srv, handler = loop.run_until_complete(init(loop))
try:
loop.run_forever()
except KeyboardInterrupt:
loop.run_until_complete(handler.finish_connections())
This http request:
POST /simpleget HTTP/1.1
User-Agent: curl/7.35.0
Host: localhost:8080
Accept: */*
Accept-Encoding: deflate, gzip
Content-Length: 1144
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
Results in this stacktrace:
Error handling request
Traceback (most recent call last):
File "(...)/aiohttp/aiohttp/server.py", line 273, in start
yield from self.handle_request(message, payload)
File "(...)/aiohttp/aiohttp/web.py", line 75, in handle_request
yield from match_info.route.handle_expect_header(request))
AttributeError: 'NoneType' object has no attribute 'handle_expect_header'
Note the GET in the "add_route" and the POST in the request.
The same request on /simplepost works fine.
I would expect a 405 response to be returned from the server.
This is not a blocking bug for me, but a bug nonetheless ;)