UnicodeDecodeError on unicode headers key vs non-ascii data bytes.

Tested with requests==1.0.4, newest at the time of writing.
Please note how it fails in the case of u'Content-Type':

```
import requests
assert requests.__version__ == '1.0.4'
assert requests.put('http://httpbin.org/put', headers={'Content-Type': 'application/octet-stream'}, data='\xff').status_code == 200
assert requests.put('http://httpbin.org/put', headers={u'Content-Type': 'application/octet-stream'}, data='\xff').status_code == 200

"""
Traceback (most recent call last):
  File "./test1.py", line 6, in <module>
    assert requests.put('http://httpbin.org/put', headers={u'Content-Type': 'application/octet-stream'}, data='\xff').status_code == 200
  File "./requests/requests/api.py", line 98, in put
    return request('put', url, data=data, **kwargs)
  File "./requests/requests/api.py", line 44, in request
    return session.request(method=method, url=url, **kwargs)
  File "./requests/requests/sessions.py", line 269, in request
    resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
  File "./requests/requests/sessions.py", line 364, in send
    r = adapter.send(request, **kwargs)
  File "./requests/requests/adapters.py", line 171, in send
    timeout=timeout,
  File "./requests/requests/packages/urllib3/connectionpool.py", line 422, in urlopen
    body=body, headers=headers)
  File "./requests/requests/packages/urllib3/connectionpool.py", line 274, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 958, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 992, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 812, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
"""
```


Ugh, god, I hate character encodings. Is it too much to simply ask you not to do that? =P

I don't have time to look into this right now, but my best guess is that we aren't considering that the headers might be `unicode` objects and encoding them into bytes. Not entirely sure where we should do that, but if someone wants to take a look they should feel free. =)


Related issues: #390, #400, #409, #421, #424.
#400 seems to have the most information.

@kennethreitz
Why was `test_unicode_headers` test (see #400)  and other valuable tests removed?


It's urllib3 not requests

Cory Benfield notifications@github.com wrote:

> Ugh, god, I hate character encodings. Is it too much to simply ask you
> not to do that? =P
> 
> I don't have time to look into this right now, but my best guess is
> that we aren't considering that the headers might be `unicode` objects
> and encoding them into bytes. Not entirely sure where we should do
> that, but if someone wants to take a look they should feel free. =)
> 
> ---
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/kennethreitz/requests/issues/1082#issuecomment-11854324


@kennethreitz
This issue is still reproducible with current `requests==1.1.0` and `python==2.7.3`.

I have created a pull-request #1181 that fixes the issue, please check it.