Fix a Python 3 string and mimetype issues in SCMClient.get_file_http().
Review Request #11663 — Created June 20, 2021 and submitted
SCMTool.get_file_http()
had a couple of Python 3 incompatibility
issues, one dealing with wrong string types when adding the
Authorization
header, and one dealing with access to the response
mimetype.The authorization header was assuming Unicode strings, both when
encoding to Base64 and when adding to the header. We needed to feed a
byte string intob64encode()
, then feed native strings into
add_header()
.For the mimetype, we were using a legacy function to fetch the mimetype
of a response, which didn't work on Python 3. This affected querying
both Git and Mercurial over HTTP. While there are replacement functions,
it's just safer to compare theContent-Type
header directly, which
this change does.Unit tests were added to cover all the
get_file_http()
logic, which
will help us avoid issues in the future.
Unit tests passed on Python 2 and 3.
Tested in production with a customer who hit this issue initially.
Summary | ID |
---|---|
0c5da4d1d6b11f518a782f2bd548d658f1beacb2 |