'After getting some strange encoding errors I started to research about
HTTP header encoding a little bit. The RFC mentions that special chars
should be encoded using in RFC 2047, which in python is achieved with:
>>> from email.header import Header
>>> h = Header()
>>> h.append(u\'Ã¡\')
>>> h.encode()
\'=?utf-8?b?w4PCoQ==?=\'
Also tested wget and curl:
wget --header "X-MyHeader: Ã " moth
curl --header "X-MyHeader: Ã " moth
And realized that both send the special char using a "simple" unicode
encoding (which actually goes against the RFC).
Afterwards I created a test script in PHP, hosted it in my local Apache
and analyzed what PHP got in each case. The test proved that neither
PHP nor Apache decode the RFC 2047 and they DO ACCEPT the unicode
encoded char.
To be sure we can send HTTP requests with special chars, which are
then correctly read by Apache/PHP, we\'re going to mimic wget/curl.
:return: string representation of the Headers() object.'

def __str__(self):

    header_str_unicode = self._to_str_with_separators(u':    ', u'\r\n')
    if header_str_unicode:
        header_str_unicode += u'\r\n'
    return header_str_unicode.encode('utf-8')
