Opened 10 years ago
Closed 10 years ago
#23773 closed Bug (duplicate)
Client().post("/someurl",data="", content_type='text/plain') results in request.body = {}
Reported by: | Ian Sparks | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If you want to access request.body in a handler function to get the raw posted data and the value posted was the empty string ""
with a content type of text/plain then what appears in request.body is a string representing an empty dictionary {}
due to this line in client.py in the RequestFactory class.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra): "Construct a POST request." post_data = self._encode_data(data or {}, content_type) # <-- Problem line
Here data is replaced with a dictionary before being passed to encoding but what I would expect to end up in request.body is the original empty string for a text/plain request.
Change History (2)
comment:1 by , 10 years ago
Description: | modified (diff) |
---|
comment:2 by , 10 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This was reported in the comments of #21740 and should be fixed in 1.7.1. Please reopen if not.