kennethreitz/requests — pull request #1181 by denis-ryzhkov (2013-02-11 12:44:21+00:00)
Title: Fix of UnicodeDecodeError on unicode header name that can be converted to ascii.

Problem
-------

Please see issue #1082.

Solution
--------

Let's fix at least Python-2 unicode issues with **header name**,
because its representation as bytes is well defined in HTTP/1.1 spec:
http://tools.ietf.org/html/rfc2616#section-4.2

message-header = field-name ":" [ field-value ]
field-name = token
token = 1*
CHAR =

So header name should always be sent as ascii.

If user provides header name that can be converted to ascii without errors,
then it should be converted, e.g. `u'Content-Type' --> 'Content-Type'`.

Otherwise a helpful error should be raised, indicating that the header name is the reason.

* Created: `test_unicode_header_name`.
* Updated: `prepare_headers`.