These issues can be demonstrated using AsyncRequestFactory:
{{{
>>> from django.test import AsyncRequestFactory
>>> rf = AsyncRequestFactory()
>>> post_request = rf.post('/submit/', {'foo': 'bar'})
>>> print(post_request.headers)
{'Host': 'testserver', 'Content-Length':
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
'Content-Type': 'multipart/form-data; boundary=BoUnDaRyStRiNg', 'Cookie':
''}
>>> print(post_request.body)
ValueError Traceback (most recent call
last)
/opt/my_project/venv/lib64/python3.6/site-packages/django/http/request.py
in body(self)
318 # Limit the maximum request data size that will be
handled in-memory.
319 if (settings.DATA_UPLOAD_MAX_MEMORY_SIZE is not None
and
--> 320 int(self.META.get('CONTENT_LENGTH') or 0) >
settings.DATA_UPLOAD_MAX_MEMORY_SIZE):
321 raise RequestDataTooBig('Request body exceeded
settings.DATA_UPLOAD_MAX_MEMORY_SIZE.')
322
ValueError: invalid literal for int() with base 10:
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32162>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* component: Uncategorized => Testing framework
--
Ticket URL: <https://code.djangoproject.com/ticket/32162#comment:1>
* status: new => assigned
* severity: Normal => Release blocker
* cc: Andrew Godwin, Carlton Gibson (added)
* owner: nobody => patrick
* has_patch: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Thanks for the report!
[https://github.com/django/django/pull/13632 PR]
#32164 was closes as a duplicate.
--
Ticket URL: <https://code.djangoproject.com/ticket/32162#comment:2>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32162#comment:3>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"542b4b3ab44d33dfd9b00c22f624ee4aed6f7534" 542b4b3a]:
{{{
#!CommitTicketReference repository=""
revision="542b4b3ab44d33dfd9b00c22f624ee4aed6f7534"
Fixed #32162 -- Fixed setting Content-Length header in
AsyncRequestFactory.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32162#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"bb74d2db98f4b2bdd2955ebf728545518a05be27" bb74d2db]:
{{{
#!CommitTicketReference repository=""
revision="bb74d2db98f4b2bdd2955ebf728545518a05be27"
[3.1.x] Fixed #32162 -- Fixed setting Content-Length header in
AsyncRequestFactory.
Backport of 542b4b3ab44d33dfd9b00c22f624ee4aed6f7534 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32162#comment:4>