kennethreitz/requests — Issue #403: Binary POST data stopped working in requests 0.10.1
Author: vimalb
Created: 2012-01-30 23:13:57+00:00
State: open

The following method for POSTing binary data worked with requests 0.10.0 on Python 2.7.1 (Ubuntu 11.04 x64) :

bodybytes = '\xDE\xAD\xBE\xEF'
r = requests.post(url, data=bodybytes)

With requests 0.10.1 on the same environment, it no longer works correctly. Specifically, the body data does not get appended correctly and passed onto the server.

A full example (including sample flask server) that works with 0.10.0 but not 0.10.1:

````
import flask, multiprocessing, requests

app = flask.Flask(__name__)

@app.route("/testpost", methods=['POST'])
def echopost():
return str(len(flask.request.data))

web_process = multiprocessing.Process(target=lambda: app.run(host='127.0.0.1', port=5000))
web_process.start()
try:
bodybytes = '\xDE\xAD\xBE\xEF'
print('Original body length = '+str(len(bodybytes)))
r = requests.post('http://127.0.0.1:5000/testpost', data=bodybytes )
print('POST body length = '+str(r.content))
assert(int(r.content) == len(bodybytes))
finally:
web_process.terminate()
````

Any idea what may have caused this change in behavior?