Opened 10 years ago
Last modified 10 years ago
#23773 closed Bug
Client().post("/someurl",data="", content_type='text/plain') results in request.body = {} — at Version 1
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.
Note:
See TracTickets
for help on using tickets.