'Encodes headers.
Note: This should be used right before
sending anything out.
:param headers: Headers to encode
:returns: Dictionary with encoded headers\'
names and values'

def _encode_headers(self, headers):

    if six.PY3:
        to_str = str
    else:
        to_str = encodeutils.safe_encode
    return {to_str(h): to_str(v) for (h, v) in six.iteritems(headers)}
