[Django] #27999: TestClient does not correctly handle 307 and 308 redirects

16 views
Skip to first unread message

Django

unread,
Mar 31, 2017, 6:04:41 AM3/31/17
to django-...@googlegroups.com
#27999: TestClient does not correctly handle 307 and 308 redirects
-----------------------------------------+------------------------
Reporter: anentropic | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
In the TestClient... 308 status is not recognised at all currently.

307 is just treated the same as the other redirects (301, 302, 303) and is
converted to a GET request, regardless of the original request method.

This is incorrect according to the RFCs... 307 and 308 redirects are
supposed to preserve the original method and request body, so a POST
request resulting in 307 response should cause the client to re-POST the
body to the new Location.

https://tools.ietf.org/html/rfc7231#section-6.4.7
https://tools.ietf.org/html/rfc7538#page-3

I'm happy to prepare a PR for this if it's agreed this should be changed.

--
Ticket URL: <https://code.djangoproject.com/ticket/27999>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 31, 2017, 8:09:13 AM3/31/17
to django-...@googlegroups.com
#27999: TestClient does not correctly handle 307 and 308 redirects
-----------------------------------+------------------------------------
Reporter: anentropic | Owner: nobody
Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Claude Paroz):

* type: Uncategorized => New feature
* version: 1.10 => master
* component: Uncategorized => Testing framework
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:1>

Django

unread,
Mar 31, 2017, 8:17:53 AM3/31/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+------------------------------------
Reporter: anentropic | Owner: nobody

Type: New feature | Status: new
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:2>

Django

unread,
May 22, 2017, 6:23:32 AM5/22/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+------------------------------------
Reporter: anentropic | Owner: Tom
Type: New feature | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tom):

* owner: nobody => Tom
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:3>

Django

unread,
May 22, 2017, 6:52:24 AM5/22/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+------------------------------------
Reporter: anentropic | Owner: Tom
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tom):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/8531

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:4>

Django

unread,
Dec 9, 2017, 6:52:58 AM12/9/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+--------------------------------------
Reporter: anentropic | Owner: Tom Forbes

Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Martin):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:5>

Django

unread,
Dec 9, 2017, 9:40:52 AM12/9/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+--------------------------------------
Reporter: anentropic | Owner: Tom Forbes
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tom Forbes):

* needs_better_patch: 1 => 0


Comment:

Not sure if I'm meant to remove this flag myself after I've made the
changes the reviewer requested, please let me know if not.

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:6>

Django

unread,
Dec 16, 2017, 5:47:36 PM12/16/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+--------------------------------------
Reporter: anentropic | Owner: Tom Forbes
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Martin):

* needs_better_patch: 0 => 1


Comment:

It's fine to clear the "patch needs improvement" flag yourself, since
that's one of the main ways reviewers can spot that it's ready to re-
review. As it happens, there are a couple more style issues (not from me)
on the patch, so I'm going to set this again for now.

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:7>

Django

unread,
Dec 23, 2017, 4:43:38 PM12/23/17
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-----------------------------------+--------------------------------------
Reporter: anentropic | Owner: Tom Forbes
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tom Forbes):

* needs_better_patch: 1 => 0


Comment:

Thanks! I've made some changes based on the reviews

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:8>

Django

unread,
Feb 2, 2018, 10:02:06 AM2/2/18
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-------------------------------------+-------------------------------------

Reporter: anentropic | Owner: Tom
| Forbes
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


Comment:

OK. Patch looks good.

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:9>

Django

unread,
Feb 6, 2018, 9:24:08 AM2/6/18
to django-...@googlegroups.com
#27999: Add test Client support for HTTP 307 and 308 redirects
-------------------------------------+-------------------------------------
Reporter: anentropic | Owner: Tom
| Forbes
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"272f685794de0b8dead220ee57b30e65c9aa097c" 272f685]:
{{{
#!CommitTicketReference repository=""
revision="272f685794de0b8dead220ee57b30e65c9aa097c"
Fixed #27999 -- Added test client support for HTTP 307 and 308 redirects.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27999#comment:10>

Reply all
Reply to author
Forward
0 new messages