-
-
Notifications
You must be signed in to change notification settings - Fork 947
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
feat(API): Support http.HTTPStatus (a proof-of-concept prototype) (#1135) #1334
Conversation
…are still remaining...
@@ -803,6 +804,10 @@ def add_link(self, target, rel, title=None, title_star=None, | |||
|
|||
""") | |||
|
|||
# @property |
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.
An open question: could something like this be of use to API users?
'supported status code' % status_code) | ||
|
||
|
||
def get_http_status_line(status): |
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.
Suggestions for a better name are very welcome as this is a bit of a misnomer.
Technically HTTP status line includes HTTP protocol, so a full status would look like HTTP/1.1 404 Not Found
.
Edit: maybe get_raw_http_status
would look better?
Raw is better |
Killing this for now, I will try to port optimizations and design changes in small increments instead. |
This is not a fully polished version, but rather a prototype. Old documentation, tutorials and Python docstrings are still largely intact. It would be awesome to first discuss the proposed changeset with @kgriffs and @jmvrbanac, and distill an acceptable technical solution first; I would be happy to contribute to the documentation afterwards.
The main design ideas laid out below are roughly in-line with the plan found in #1135 :
Response.status
shall be set tohttp.HTTPStatus
, or its backport to older Python versions found infalcon.util.status_enum
http.HTTPStatus
subclasses anint
viaIntEnum
)falcon.util.status_enum
, a base HTTP status enum class is defined similarly tohttp.HTTPStatus
; that is used to support other non-standard status codes previously included in Falcon [1]Somewhat controversial ramifications:
falcon.status_codes.COMBINED_STATUS_CODE
lookup table. This could be made easier by either implementing support for legacy raw status, or probably by moving some part of this machinery toResponse
class, and documenting how and what to override to cram arbitrary status in; most probably both alternatives would come at a performance cost.Other issues:
falcon.HTTP_XXX
are raw string statuses and using those values to check response status). @timothycrosley might now more, but from what I have seen in hug source code, it usesfalcon.HTTP_XXX
constants in a clean fashion, so it is just a problem with a couple of unit tests, not Hug API functionality.