{{{
def my_view(request):
content = request.body
# some actions with content varible
response = HttpResponse('<h1>It work!</h1>')
}}}
And a simple api client, let's say based on the requests library, sending
malformed Django view data:
{{{
headers = dict()
headers['Accept'] = '*/*'
headers['Content-Length'] = '13409'
headers['Content-Type'] = 'application/x-compressed'
headers['Expect'] = '100-continue'
headers['Host'] = '127.0.0.1:8000'
headers['User-Agent'] = 'Api client'
headers['content-encoding'] = 'gzip'
url = 'http://127.0.0.1:8000/api'
request_body = ''
r = requests.post(
url,
data=request_body,
headers=headers
)
}}}
As you can see, request_body contains an empty string, but the Content-
Length header stores the value 13409. When such a request arrives, Django
hangs on the line reading request.body. No exceptions occur. How to solve
this problem? I cannot influence the client, so the only thing I can do is
rewrite the Django view. Django version 3.2.15 is used.
--
Ticket URL: <https://code.djangoproject.com/ticket/33926>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #29800
--
Ticket URL: <https://code.djangoproject.com/ticket/33926#comment:1>
* status: closed => new
* resolution: duplicate =>
--
Ticket URL: <https://code.djangoproject.com/ticket/33926#comment:2>
* status: new => closed
* resolution: => duplicate
Comment:
Hi Maksim.
Claude marked this as a duplicate. If you don't agree, and want to reopen,
could you also provide a comment as to why you think it's distinct.
Otherwise let's continue on #29800. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/33926#comment:3>