Opened 3 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 Tom Hamilton Stubber, 3 years ago

Owner: changed from nobody to Tom Hamilton Stubber
Status: newassigned

comment:3 by Tom Hamilton Stubber, 3 years ago

Triage Stage: UnreviewedReady for checkin

comment:4 by Mariusz Felisiak, 3 years ago

Triage Stage: Ready for checkinUnreviewed

You shouldn't accept or mark as RFC your own tickets/PRs.

comment:5 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

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 Carlton Gibson, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Carlton Gibson <carlton.gibson@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 1e5aa8e1:

Fixed #32790 -- Ensured test Client handles redirects to domain indexes without a specified trailing slash.

Note: See TracTickets for help on using tickets.
Back to Top