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


None yet
2 participants
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 < connected at 0x17ed609aa90> (<class 'TypeError'>:decoding to str: need a bytes-like object, NoneType found [|read|83] [|handle_read_event|423] [lib\site-packages\waitress\|handle_read|174] [lib\site-packages\waitress\|received|191] [lib\site-packages\waitress\|received|102] [lib\site-packages\waitress\|parse_header|201] [lib\site-packages\waitress\|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.


This comment has been minimized.

Copy link

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.


This comment has been minimized.

Copy link

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.