#35051: HEAD Responses Drop Headers
-----------------------------------------+------------------------
               Reporter:  Paul Bailey    |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  5.0
               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              |
-----------------------------------------+------------------------
 When using runserver headers are dropped for head requests, in particular
 content-length. Because my HEAD request is serving a large body content, I
 do not include it in the body since it is just dropped.

 Headers from runserver:
 {{{#!python
 Headers({'date': 'Tue, 19 Dec 2023 12:52:23 GMT', 'server':
 'WSGIServer/0.2 CPython/3.11.2', 'accept-ranges': 'bytes', 'content-type':
 'text/html; charset=utf-8', 'x-frame-options': 'DENY', 'x-content-type-
 options': 'nosniff', 'referrer-policy': 'same-origin', 'cross-or
 igin-opener-policy': 'same-origin'})
 }}}

 Headers from uvicorn asgi server:
 {{{#!python
 Headers({'date': 'Tue, 19 Dec 2023 12:54:49 GMT', 'server': 'uvicorn',
 'accept-ranges': 'bytes', 'content-length': '121283919', 'content-type':
 'text/html; charset=utf-8', 'x-frame-options': 'DENY', 'x-content-type-
 options': 'nosniff', 'referrer-policy': 'same-origin', 'cross-origin-
 opener-policy': 'same-origin'})
 }}}

 Notice the uvicorn properly includes the content-length header that was
 set in the view.

 View source snippet:
 {{{#!python
 if request.method == 'HEAD':
     print('HEAD Request')
     return HttpResponse(headers={
         'Accept-Ranges': 'bytes',
         'Content-Length': str(file_size)
       })
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018c823749cc-1f98573c-9328-49fc-b964-936b66ea6659-000000%40eu-central-1.amazonses.com.

Reply via email to