python-requests的post

python requests Content-Length

​How not to let python requests calculate content-length and use the provided one? - Stack Overflow​

from requests import Request, Session

s = Session()

req = Request('POST', url, data=data, headers=headers)
prepped = req.prepare()

# do something with prepped.headers
prepped.headers['Content-Length'] = your_custom_content_length_calculation()

resp = s.send(prepped, ...)


requests post 修改了Content-Length