-
Notifications
You must be signed in to change notification settings - Fork 178
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
No longer allow lowercase HTTP methods #170
Conversation
Closes #154 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a counter point <form method=post>
is valid... but that's the html spec, not http. Anyway I don't think it's important for waitress to accept non-compliant verbs.
waitress/parser.py
Outdated
command = m.group(1).upper() | ||
method = m.group(1) | ||
|
||
# the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment could use a couple more iterations and design meetings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems I forgot to commit after adding the comment. Done now.
waitress/parser.py
Outdated
|
||
# the | ||
if method != method.upper(): | ||
raise ParsingError('Malformed HTTP method "%s"' % tostr(method)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to force it to be upper specifically instead of just passing it through untouched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, nginx and other servers drop the incoming request on the floor. This caused me a lot of headache and debugging issues when I was testing with waitress locally and using nginx in production.
All currently defined HTTP methods are uppercase, I don't think it is a bad idea to enforce that.
70e916f
to
e3ad2a3
Compare
Yes, and browsers unconditionally turn that into a |
…1.1.0 1.1.0 (2017-10-10) ------------------ Features ~~~~~~~~ - Waitress now has a __main__ and thus may be called with ``python -mwaitress`` Bugfixes ~~~~~~~~ - Waitress no longer allows lowercase HTTP verbs. This change was made to fall in line with most HTTP servers. See Pylons/waitress#170 - When receiving non-ascii bytes in the request URL, waitress will no longer (NEWS truncated at 15 lines)
RFC 7231 specifies that methods are case sensitive, and by convention are all uppercase: https://tools.ietf.org/html/rfc7231#section-4.1
https://tools.ietf.org/html/rfc7231#section-8.1 specifies that there is a registry for all of the HTTP methods that exist, which is available here: https://www.iana.org/assignments/http-methods/http-methods.xhtml (in other news, there are a lot more there than I was aware of :P)
All of them are uppercase.
I recently ran into an interesting issue, I was using the new
fetch()
function in JavaScript and it allowed me to send apost
request instead of aPOST
request. nginx dropped the request on the floor, but waitress locally was allowing it by just calling.upper()
on the method.This change brings things more in line with all other HTTP servers, and disallows anything put an uppercase HTTP method thereby hopefully making it harder to have differences between prod and devel...