Opened 4 years ago
Closed 3 years ago
#32790 closed Bug (fixed)
Django test client redirecting to URLs without a trailing slash redirects instead to the current view
Reported by: | Tom Hamilton Stubber | Owned by: | Tom Hamilton Stubber |
---|---|---|---|
Component: | Testing framework | Version: | 3.2 |
Severity: | Normal | Keywords: | Test client |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, when you redirect with the test client to an external URL without a trailing slash, the test client will redirect to the view you redirected from.
For example, if I test a view at /my-view/
that redirects to https://example.com
, the test client will instead redirect to /my-view/
.
Presumably this isn't intended behaviour but feel free to correct me.
Change History (7)
comment:1 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 4 years ago
comment:3 by , 4 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
comment:4 by , 4 years ago
Triage Stage: | Ready for checkin → Unreviewed |
---|
You shouldn't accept or mark as RFC your own tickets/PRs.
comment:5 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I think this is probably valid. I su
RFC 2616 (HTTP/1.1) has this for an HTTP URL:
http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
It then says:
If the abs_path is not present in the URL, it MUST be given as "/" when used as a Request-URI for a resource.
i.e. the client MUST treat https://example.com
as https://example.com/
.
(Inclined towards thinking this should probably apply to the Location
headers set by the server too, but the test client can't control for that.)
comment:6 by , 3 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR https://github.com/django/django/pull/14457