kennethreitz/requests — Issue #400: Unfortunate header unicode interactions
Author: acdha
Created: 2012-01-30 00:19:28+00:00
State: open

header_expand (https://github.com/kennethreitz/requests/blob/develop/requests/utils.py#L149) has a fast path which only supports str. Unfortunately, response.url will contain a unicode string which means that anyone doing something like requests.get(response.url, headers={'Referer': response.url}) will get a ValueError from header_expand.

Does it make more sense to simply make the ``header_expand`` check do ``if isinstance(headers, basestring)`` or have an explicit ``if isinstance(headers, unicode): return headers.encode("utf-8")`` instead? I'm happy to test either way.