Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'handle_expect_header' #340

Closed
iCart opened this issue Apr 22, 2015 · 3 comments
Closed
Labels

Comments

@iCart
Copy link

iCart commented Apr 22, 2015

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 ;)

@fafhrd91
Copy link
Member

good catch!

@iCart
Copy link
Author

iCart commented Apr 22, 2015

Wow, that was fast!
Thanks for your excellent work!

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants