[Django] #28054: After #26052 runserver returns response body for HTTP HEAD requests

33 views
Skip to first unread message

Django

unread,
Apr 7, 2017, 11:05:36 AM4/7/17
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-----------------------------------------+---------------------------
Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: 1.10
Severity: Normal | Keywords: runserver
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+---------------------------
For compliance with RFC 2616, section 4.3, response bodies must not be
returned for HEAD requests.

In #26052, the stripping of the response bodies was removed from Django in
favour of letting the server perform the body removal, since the common
servers (gunicorn, mod_wsgi etc) already do so.

However it appears that runserver does not strip the body, contrary to:
https://code.djangoproject.com/timeline?from=2016-04-23T20%3A26%3A34-05%3A00&precision=second

As such, starting in Django 1.10 the responses from runserver for HEAD
requests are no longer compliant with the spec. (In certain configurations
this also results in "Broken pipe" error messages in runserver output,
since compliant user agents expect to be able to terminate the connection
after the headers are sent.)

STR:
1) `mkvirtualenv django-test`
2) `pip install 'Django>1.10,<1.11'`
3) `django-admin startproject django-test`
4) `cd django-test`
5) `./manage.py runserver`
6) In another terminal, run `curl -iX HEAD http://127.0.0.1:8000/`
7) Observe response from curl

Expected:
{{{
HTTP/1.0 200 OK
Date: Fri, 07 Apr 2017 14:56:39 GMT
Server: WSGIServer/0.2 CPython/3.4.5
Content-Type: text/html
X-Frame-Options: SAMEORIGIN
}}}

Actual:
{{{
HTTP/1.0 200 OK
Date: Fri, 07 Apr 2017 14:56:39 GMT
Server: WSGIServer/0.2 CPython/3.4.5
Content-Type: text/html
X-Frame-Options: SAMEORIGIN


<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE"><title>Welcome to
Django</title>
...
}}}

Tested with Python 2.7.13 and 3.4.5.
Doesn't reproduce under Django 1.9.13.

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

Django

unread,
Apr 7, 2017, 11:16:04 AM4/7/17
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------+--------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: 1.10
Severity: Normal | Resolution:

Keywords: runserver | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Ed Morley):

Also this comment now seems incorrect:
https://github.com/django/django/blob/5d3b322dce452dd75e8602ced9f0d02f9d6a5837/django/middleware/http.py#L15-L19

...in that the body won't be empty as far as middleware is concerned for
HEAD requests.

The spec says entity tag validators can still be set for HEAD requests:
https://tools.ietf.org/html/rfc7232#section-2.4

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

Django

unread,
Apr 7, 2017, 1:11:44 PM4/7/17
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | 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):

* component: HTTP handling => Core (Management commands)
* stage: Unreviewed => Accepted


Comment:

Looks like another impetus for switching `runserver` to use another web
server when feasible (#21978).

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

Django

unread,
Sep 17, 2021, 11:15:09 AM9/17/21
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Dave Johansen):

* cc: Dave Johansen (added)


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

Django

unread,
Oct 26, 2021, 4:07:15 AM10/26/21
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

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

#29343 was a duplicate.

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

Django

unread,
Jan 25, 2023, 3:37:32 AM1/25/23
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------

Reporter: Ed Morley | Owner: nobody
Type: Bug | Status: new
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Sarah Boyce (added)


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

Django

unread,
Jan 26, 2023, 4:22:44 AM1/26/23
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: Sarah
| Boyce
Type: Bug | Status: assigned

Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* owner: nobody => Sarah Boyce
* needs_better_patch: 1 => 0
* status: new => assigned
* needs_tests: 1 => 0


Comment:

https://github.com/django/django/pull/16502

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

Django

unread,
Jan 27, 2023, 4:48:15 AM1/27/23
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: Sarah
| Boyce
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution:
Keywords: runserver | 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 Mariusz Felisiak):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 27, 2023, 3:50:07 PM1/27/23
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: Sarah
| Boyce
Type: Bug | Status: closed

Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution: fixed

Keywords: runserver | 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 GitHub <noreply@…>):

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


Comment:

In [changeset:"8acc433e415cd771f69dfe84e57878a83641e78b" 8acc433e]:
{{{
#!CommitTicketReference repository=""
revision="8acc433e415cd771f69dfe84e57878a83641e78b"
Fixed #28054 -- Made runserver not return response body for HEAD requests.

Co-authored-by: jannschu <jannik....@posteo.de>
}}}

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

Django

unread,
Jan 27, 2023, 3:51:12 PM1/27/23
to django-...@googlegroups.com
#28054: After #26052 runserver returns response body for HTTP HEAD requests
-------------------------------------+-------------------------------------
Reporter: Ed Morley | Owner: Sarah
| Boyce
Type: Bug | Status: closed
Component: Core (Management | Version: 1.10
commands) |
Severity: Normal | Resolution: fixed
Keywords: runserver | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"4bf3d6dec299dca26f9fa3782e143c6f20e6e56b" 4bf3d6de]:
{{{
#!CommitTicketReference repository=""
revision="4bf3d6dec299dca26f9fa3782e143c6f20e6e56b"
[4.2.x] Fixed #28054 -- Made runserver not return response body for HEAD
requests.

Co-authored-by: jannschu <jannik....@posteo.de>
Backport of 8acc433e415cd771f69dfe84e57878a83641e78b from main
}}}

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

Reply all
Reply to author
Forward
0 new messages