Opened 10 years ago
Closed 10 years ago
#24145 closed Bug (fixed)
Extend POST redirect error to be raised on PUT and PATCH
Reported by: | Samuel Colvin | Owned by: | Samuel Colvin |
---|---|---|---|
Component: | Core (Other) | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | tom@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
As per https://github.com/tomchristie/django-rest-framework/issues/2405 discussion it would be extremely helpful if the exception raised when POST requests require a redirect
raise RuntimeError((""
"You called this URL via POST, but the URL doesn't end "
"in a slash and you have APPEND_SLASH set. Django can't "
"redirect to the slash URL while maintaining POST data. "
"Change your form to point to %s%s (note the trailing "
"slash), or set APPEND_SLASH=False in your Django "
"settings.") % (new_url[0], new_url[1]))
was extended to PUT and PATCH requests. PUT and PATCH requests have associated data which is generally lost with a redirect.
Code: https://github.com/django/django/blob/1.7.2/django/middleware/common.py#L75
Change History (10)
comment:1 by , 10 years ago
Cc: | added |
---|---|
Component: | contrib.redirects → Core (Other) |
Easy pickings: | set |
Triage Stage: | Unreviewed → Accepted |
Type: | New feature → Bug |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Since it was easy I took the chance to try and get myself on the list of django contributors: https://github.com/django/django/pull/3908
comment:4 by , 10 years ago
Has patch: | set |
---|
comment:5 by , 10 years ago
@samuelcolvin please assign this geck to yourself. It is seems to have a solution you had developed, but looks as if it is not triaged.
comment:6 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 10 years ago
Needs tests: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
I think some tests wouldn't hurt here (not sure if there's one for the existing behavior).
comment:9 by , 10 years ago
Needs tests: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I'm going to second this one. Our options are:
PUT
andPATCH
and continue issuing the 500 response.PUT
andPATCH
, but use an 307 (or 308) redirect, which is spec'ed as not allowing a rewrite-to-GET request. See: http://trac.tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-21#section-7.4.7Of these, the first is the lesser change. It's unclear to me how widely supported 307/308 responses are supported by browsers and other clients.