diff options
| author | Carlton Gibson <carlton.gibson@noumenal.es> | 2024-04-05 10:24:36 +0200 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2024-04-05 11:35:38 +0200 |
| commit | bcd255cd5ca0a1e686d276cca71f45ec400d84a2 (patch) | |
| tree | 1e3e582e6f797ae21cf9e2670972156f712ca65f /django | |
| parent | 4d2ef9bb826db76acb5ed7609a9162de9b651921 (diff) | |
Fixed #35354 -- Simplified ASGIRequest path handling.
Following the ASGI HTTP Connection Scope docs[0], the provided `path`
is already the correct value that Django requires.
In combination with `root_path`, from which `script_name` is derived,
the `path_info` variable is set. It's then redundant to
re-calculate `path` from `script_name` and `path_info`.
See also, a clarifying discussion on the ASGIref repo[1].
[0]: https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope
[1]: https://github.com/django/asgiref/issues/424
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/handlers/asgi.py | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/django/core/handlers/asgi.py b/django/core/handlers/asgi.py index 3af080599a..bb6a6bfb3c 100644 --- a/django/core/handlers/asgi.py +++ b/django/core/handlers/asgi.py @@ -50,21 +50,13 @@ class ASGIRequest(HttpRequest): self._post_parse_error = False self._read_started = False self.resolver_match = None + self.path = scope["path"] self.script_name = get_script_prefix(scope) if self.script_name: # TODO: Better is-prefix checking, slash handling? self.path_info = scope["path"].removeprefix(self.script_name) else: self.path_info = scope["path"] - # The Django path is different from ASGI scope path args, it should - # combine with script name. - if self.script_name: - self.path = "%s/%s" % ( - self.script_name.rstrip("/"), - self.path_info.replace("/", "", 1), - ) - else: - self.path = scope["path"] # HTTP basics. self.method = self.scope["method"].upper() # Ensure query string is encoded correctly. |
