-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
SansIO Wrappers #2005
SansIO Wrappers #2005
Conversation
src/werkzeug/wrappers/request.py
Outdated
@property | ||
def is_secure(self) -> bool: | ||
"`True` if the request is secure." | ||
return self.scheme in {"https", "wss"} |
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 is a change from the previous code, but I think it makes sense.
a06c412
to
2bf997c
Compare
Why were only some of the WSGI values extracted? https://asgi.readthedocs.io/en/latest/specs/www.html#wsgi-compatibility It seems like you'd also want at least |
I'm not sure I've updated with REMOTE_ADDR usage, thanks. |
The link I posted suggests Could you give a brief outline on the issues with |
Updated the script_info usage, to use See also django/asgiref#229 for a potential issue with ASGI and root_path. |
This might be clearer if you consider the names as `BaseRequest` and `WSGIRequest` (although these names aren't possible for compatibility reasons). The `SansIORequest` contains all the information that is not WSGI or IO dependent thereby allowing it to be used in ASGI projects, notably Quart. This has a very slight performance impact as the path, scheme, headers, and method are no longer lazily loaded. However, this impact is likely just a dictionary lookup. The changes in other files are minor typing improvements related to the typing changed in the request wrappers.
This might be clearer if you consider the names as `BaseResponse` and `WSGIResponse` (although these names aren't possible for compatibility reasons). The `SansIOResponse` contains all the information that is not WSGI or IO dependent thereby allowing it to be used in ASGI projects, notably Quart.
This makes the naming a little easier (called request and response), and allows the sansio module to be considered private/development. The latter is desired as it isn't clear (yet) how to specify the IO interface - in an abstract manner so that both sync and async implementations exist. This also allows further sansio, rather than WSGI based code, to be added in a clear location - clear to future authors that the code must not be WSGI or ASGI or IO specific.
Thanks! |
This might be clearer if you consider the names as
BaseRequest
/BaseResponse
andWSGIRequest
/WSGIResponse
(although these names aren't possible for compatibility reasons). TheSansIORequest
/SansIOResponse
contains all the information that is not WSGI or IO dependent thereby allowing it to be used in ASGI projects, notably Quart.Does this need specific docs? (At this stage?)
Checklist:
CHANGES.rst
summarizing the change and linking to the issue... versionchanged::
entries in any relevant code docs.pre-commit
hooks and fix any issues.pytest
andtox
, no tests failed.