kennethreitz/requests — Issue #444: UnicodeDecodeError when posting a Multipart-Encoded binary File
Author: cedricbonhomme
Created: 2012-02-20 07:19:16+00:00
State: open

I think that there is still a bug related to the bug #403.

```python
>>> files = {"xml": open("photos.xml", "r"), "image": open("Vienna-Orchestra.jpg", "rb")}
>>> r = requests.post(url, files=files, auth=('***', '***'))
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-i686/egg/requests/api.py", line 84, in post
File "build/bdist.linux-i686/egg/requests/api.py", line 39, in request
File "build/bdist.linux-i686/egg/requests/sessions.py", line 200, in request
File "build/bdist.linux-i686/egg/requests/models.py", line 535, in send
File "build/bdist.linux-i686/egg/requests/packages/urllib3/connectionpool.py", line 370, in urlopen
File "build/bdist.linux-i686/egg/requests/packages/urllib3/connectionpool.py", line 246, in _make_request
File "/usr/local/lib/python2.7/httplib.py", line 946, in request
self._send_request(method, url, body, headers)
File "/usr/local/lib/python2.7/httplib.py", line 987, in _send_request
self.endheaders(body)
File "/usr/local/lib/python2.7/httplib.py", line 940, in endheaders
self._send_output(message_body)
File "/usr/local/lib/python2.7/httplib.py", line 801, in _send_output
msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 484: ordinal not in range(128)
```

I've made different tests and always get the same problem. It works quite well if the photo is a simple text file.