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

Fix error when HTTP version is missing in Python 3 #221

Conversation

Projects
None yet
2 participants
@andrewisplinghoff
Copy link

commented Nov 23, 2018

I encountered the following error in the log of our web server running waitress 1.1.0 on Python 3.6.1:

uncaptured python exception, closing channel <waitress.channel.HTTPChannel connected 140.10.xxx.xxx:37060 at 0x17ed609aa90> (<class 'TypeError'>:decoding to str: need a bytes-like object, NoneType found [asyncore.py|read|83] [asyncore.py|handle_read_event|423] [lib\site-packages\waitress\channel.py|handle_read|174] [lib\site-packages\waitress\channel.py|received|191] [lib\site-packages\waitress\parser.py|received|102] [lib\site-packages\waitress\parser.py|parse_header|201] [lib\site-packages\waitress\compat.py|tostr|53])

The problem comes from the variable version being set to None if it is missing in the request and being transformed to a string afterwards.

version = None

version = tostr(version)

The suggested fix improves the Python 3 compatibility function to handle None values the same way as Python 2 does. Another fix would be of course to not try to convert None to a string in the first place.

@bertjwregeer

This comment has been minimized.

Copy link
Member

commented Nov 24, 2018

It should instead be changed to ignore the request entirely/return an error to the requesting client. If crack first line is unable to figure out the HTTP version used, then it is not something that Waitress can properly deal with in the first place.

See #110 for a similar issue.

Instead of converting it to None as a string, we should reject the request.

@bertjwregeer

This comment has been minimized.

Copy link
Member

commented Apr 13, 2019

I've just accepted and merged #252 instead of this patch, thanks for your contribution and apologies for sitting on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.