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

utils.http_util.Response uses invalid status arguments to WSGI start_response #515

Closed
schlenk opened this issue Mar 31, 2018 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@schlenk
Copy link
Collaborator

schlenk commented Mar 31, 2018

Introduced by the refactoring of status/status_code in #495

Response calls the WSGI defined start_response callback with the integer status code directly.
According to the docs, the first argument must be a string not an integer.

https://www.python.org/dev/peps/pep-0333/#the-start-response-callable

The status argument is an HTTP "status" string like "200 OK" or "404 Not Found". That is, it is a string consisting of a Status-Code and a Reason-Phrase, in that order and separated by a single space, with no surrounding whitespace or other characters. (See RFC 2616, Section 6.1.1 for more information.) The string must not contain control characters, and must not be terminated with a carriage return, linefeed, or combination thereof.

Probably just needs something like:

name = httplib.responses.get(status_code, 'UNKNOWN')
status = "%d %s" % (status_code, name)
@tpazderka tpazderka added the bug label Apr 6, 2018
@tpazderka tpazderka self-assigned this Apr 6, 2018
@tpazderka tpazderka added this to the 0.14.0 milestone Apr 6, 2018
@tpazderka
Copy link
Collaborator

This was introduced even prior and is broken in current release 0.13.0. I think we should we fix it in a bugfix...

@tpazderka tpazderka modified the milestones: 0.14.0, 0.13.1 Apr 6, 2018
@schlenk
Copy link
Collaborator Author

schlenk commented Apr 6, 2018

Yes, stumbled on it while integrating 0.13.0 in my work project.

The string part in the WSGI start_response code is probably needed to send/proxy atrocities like Microsofts IIS http error codes (https://support.microsoft.com/en-us/help/943891/the-http-status-code-in-iis-7-0-iis-7-5-and-iis-8-0 for example you can get junk like "403.6 IP Address Rejected"), which totally violates RFC 7230.

@tpazderka
Copy link
Collaborator

OK. Bugfix is out and changes merged to master as well.

andrewkrug pushed a commit to mozilla-iam/pyoidc that referenced this issue Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants