#29800: Django hangs when Content-Length has incorrect value
-------------------------------------+-------------------------------------
     Reporter:  Alexander Charykov   |                    Owner:  Lakshya
                                     |  Prasad
         Type:  Bug                  |                   Status:  assigned
    Component:  HTTP handling        |                  Version:  2.1
     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
-------------------------------------+-------------------------------------
Comment (by Lakshya Prasad):

 After investigating further, I was able to reproduce the issue where
 Django appears to hang when a request is sent with a Content-Length header
 larger than the actual payload.

 Tracing the code path shows that `request.body` ultimately calls
 `environ['wsgi.input'].read()`, which blocks until the number of bytes
 specified by Content-Length is fully read. Since fewer bytes are actually
 sent, the read operation does not complete, causing the request to hang.

 This behavior seems to originate from the WSGI layer (e.g., `wsgiref` or
 `gunicorn`) rather than Django itself. Additionally, the WSGI
 specification does not define how to handle cases where Content-Length
 exceeds the actual payload.

 Given that Django is typically deployed behind a reverse proxy (such as
 nginx), which buffers and validates request bodies, this issue is unlikely
 to impact production environments.

 Based on this, I’d like to propose documenting this behavior rather than
 attempting to modify Django’s request handling. I can work on a
 documentation patch if this approach is acceptable.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/29800#comment:19>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019d1a2312a9-983e2578-8494-4cca-87bc-c0cd21ed167d-000000%40eu-central-1.amazonses.com.

Reply via email to