Comment 2 for bug 1904551

Revision history for this message
Peter Uittenbroek (puittenbroek) wrote :

Okay, that reason sort of makes sense. Think the snow flake + snowman is an extreme example but does show unicode problems.

The problem that I have now is that due to the monkeypatch being applied this way, any other package using requests is affected.
In my current case, my headers (keys) are all byte strings and I end up sending 'Accept-Encoding' and 'Content-Length' twice due to python's http client not recognizing the byte-string version in it's if statement.

    > /home/uittenbroek/.pyenv/versions/3.6.10/lib/python3.6/http/client.py(1270)_send_request()
    ipdb> header_names
    frozenset({b'authorization', b'accept', b'content-length', 'content-length', b'accept-encoding', b'connection', b'user-agent'})
    ipdb> 'accept-encoding' in header_names
    False

The 'Accept-Encoding' values are:
Accept-Encoding: identity
Accept-Encoding: gzip, deflate

Guessing the first (or being send twice) causes problems for me at this instance.

So I think the monkeypatch being applied should be way more defensive, fix there what breaks for you.