Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#30582 closed New feature (wontfix)

Redirect by using 307/308 instead of 301/302.

Reported by: Yoshiki Shibukawa Owned by: nobody
Component: HTTP handling Version: dev
Severity: Normal Keywords: redirect statuscode
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Now, Django uses 301/302 to redirect. This status codes' behaviors are undefined because of historical reason.
RFC-7231 and RFC-7238 introduce new status code 307/308 for more strict usage. These status codes don't allow changing method during redirection.

If Django users mistake form POST URL (and if the URL doesn't end with "/"), Django returns 301 to redirect new URL with trailing slash. But common browsers change method and send GET request to the new URL. Then user gets weird status code "405 Method Not Allowed" with GET. If Django uses 308 instead 301, users will get more meaningful status code like 404 or 201 (if trailing slash would be collect).

Unfortunately, Only IE 11 on Windows 7/8/8.1 don't support 307/308 now (IE11 on Windows 10 supports). And Windows 8.1 lives until 2023. So I made patch that checks user-agent and return 307/308 or 301/302.

Change History (3)

comment:1 Changed 4 years ago by Yoshiki Shibukawa

Summary: Redirect by using 307/308 instead of 310/302Redirect by using 307/308 instead of 301/302

comment:2 Changed 4 years ago by Mariusz Felisiak

Has patch: unset
Resolution: wontfix
Status: newclosed
Summary: Redirect by using 307/308 instead of 301/302Redirect by using 307/308 instead of 301/302.

Thanks for the proposition. As you described 307/308 do not allow changing the request method from POST to GET, so this change is backward incompatible am I'm not sure if this should be a default Django behavior.

Please start a discussion on the DevelopersMailingList, we can re-open this ticket if we reach a consensus on a mailing list.

comment:3 Changed 4 years ago by Yoshiki Shibukawa

OK, I understand.

I notified my fix is wrong. In some cases programmers assume method change (e.g. POST then move to result page).

I think adding two new redirect classes is better way to support 307/308.

thank you. I will discuss.

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