def post_raw_data(self, path, post_data):
"""
The built-in test client's post() method assumes the data you pass
is a dictionary and encodes it. If we just want to pass the data
unmodified, we need our own version of post().
"""
parsed = urlparse(path)
r = {
'CONTENT_LENGTH': len(post_data),
'CONTENT_TYPE': "text/plain",
'PATH_INFO': self.client._get_path(parsed),
'QUERY_STRING': force_str(parsed[4]),
'REQUEST_METHOD': str('POST'),
'wsgi.input': FakePayload(post_data),
}
# Add the request signature to the headers being sent.
r.update(self.get_signature(path, method='POST', body=post_data))
# Make the actual request.
return self.client.request(**r)
评论列表
文章目录