[Django] #28081: django.test.client:conditional_content_removal() is not compliant with RFC7230

14 views
Skip to first unread message

Django

unread,
Apr 14, 2017, 11:18:42 AM4/14/17
to django-...@googlegroups.com
#28081: django.test.client:conditional_content_removal() is not compliant with
RFC7230
---------------------------------------------+------------------------
Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: master
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 |
---------------------------------------------+------------------------
[https://tools.ietf.org/html/rfc7230#section-3.3.2 RFC7230 section 3.3.2]
says:
> A server MAY send a Content-Length header field in a 304 (Not Modified)
response to a conditional GET request (Section 4.1 of [RFC7232]); a server
MUST NOT send Content-Length in such a response unless its field-value
equals the decimal number of octets that would have been sent in the
payload body of a 200 (OK) response to the same request.
>
> A server MUST NOT send a Content-Length header field in any response
with a status code of 1xx (Informational) or 204 (No Content). A server
MUST NOT send a Content-Length header field in any 2xx (Successful)
response to a CONNECT request (Section 4.3.6 of [RFC7231]).

However `conditional_content_removal()` sets `Content-Type: 0` in these
cases:
https://github.com/django/django/blob/941b8691351d4739cd9391b0a1326abd0b1c29c0/django/test/client.py#L91-L108

...which is not compliant with the specification.

The fix is to not set `Content-Type` at all in
`conditional_content_removal()`.

Note: After #26052 `conditional_content_removal()` is only used by the
`django.test.client`, though that caused the regression #28054, for which
the fix will be making runserver use it too.

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

Django

unread,
Apr 15, 2017, 8:36:15 AM4/15/17
to django-...@googlegroups.com
#28081: django.test.client:conditional_content_removal() is not compliant with
RFC7230
-----------------------------------+------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | 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 Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
May 1, 2017, 6:27:02 AM5/1/17
to django-...@googlegroups.com
#28081: django.test.client:conditional_content_removal() is not compliant with
RFC7230
-----------------------------------+--------------------------------------
Reporter: Ed Morley | Owner: João Silva
Type: Bug | 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 João Silva):

* owner: nobody => João Silva
* status: new => assigned


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

Django

unread,
May 1, 2017, 9:09:23 AM5/1/17
to django-...@googlegroups.com
#28081: django.test.client:conditional_content_removal() is not compliant with
RFC7230
-----------------------------------+--------------------------------------
Reporter: Ed Morley | Owner: João Silva
Type: Bug | 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 Tim Graham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8445 PR]

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

Django

unread,
May 9, 2017, 2:55:19 PM5/9/17
to django-...@googlegroups.com
#28081: django.test.client:conditional_content_removal() is not compliant with
RFC7230
-----------------------------------+--------------------------------------
Reporter: Ed Morley | Owner: João Silva
Type: Bug | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed
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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"3db84b5526a16a136862381c6f8b08c59da4cb82" 3db84b55]:
{{{
#!CommitTicketReference repository=""
revision="3db84b5526a16a136862381c6f8b08c59da4cb82"
Fixed #28081 -- Stopped setting Content-Length=0 in
conditional_content_removal() per RFC 7230.
}}}

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

Reply all
Reply to author
Forward
0 new messages