Open
Description
After calling prepare() on a request, PreparedRequest object is returned. If its a PATCH request (GET is working as expected), and prepare_headers is called, it's not possible to send this request.
Expected Result
Headers should be added to a prepared request and it should be possible to send it later.
Actual Result
An exception is thrown:
Traceback (most recent call last):
File "r.py", line 7, in <module>
s.send(r)
File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 466, in send
low_conn.send(hex(len(i))[2:].encode('utf-8'))
TypeError: object of type 'int' has no len()
Reproduction Steps
import requests
r = requests.Request('PATCH', 'http://domain.com/objects/32', json={'name': 'new name'})
r = r.prepare()
s = requests.Session()
r.prepare_headers({'Authorization': 'Token 123'})
s.send(r)
System Information
$ python -m requests.help
{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": ""
},
"idna": {
"version": "2.7"
},
"implementation": {
"name": "CPython",
"version": "3.6.6"
},
"platform": {
"release": "4.9.87-linuxkit-aufs",
"system": "Linux"
},
"pyOpenSSL": {
"openssl_version": "",
"version": null
},
"requests": {
"version": "2.19.1"
},
"system_ssl": {
"version": "1010006f"
},
"urllib3": {
"version": "1.23"
},
"using_pyopenssl": false
}