diff --git a/vcsserver/base.py b/vcsserver/base.py --- a/vcsserver/base.py +++ b/vcsserver/base.py @@ -137,7 +137,7 @@ def archive_repo(walker, archive_dest_pa class BinaryEnvelope(object): - def __init__(self, value, bin_type=True): + def __init__(self, value: bytes, bin_type=True): self.value = value self.bin_type = bin_type diff --git a/vcsserver/hgcompat.py b/vcsserver/hgcompat.py --- a/vcsserver/hgcompat.py +++ b/vcsserver/hgcompat.py @@ -72,7 +72,8 @@ from mercurial import strip as hgext_str def get_ctx(repo, ref): - ref = safe_bytes(ref) + if not isinstance(ref, int): + ref = safe_bytes(ref) try: ctx = repo[ref] except (ProgrammingError, TypeError): diff --git a/vcsserver/http_main.py b/vcsserver/http_main.py --- a/vcsserver/http_main.py +++ b/vcsserver/http_main.py @@ -507,6 +507,7 @@ class HTTPApplication(object): bin_type = False res = value.get('result') if res and isinstance(res, BinaryEnvelope): + log.debug('Result is wrapped in BinaryEnvelope type') value['result'] = res.value bin_type = res.bin_type @@ -516,6 +517,8 @@ class HTTPApplication(object): ct = response.content_type if ct == response.default_content_type: response.content_type = 'application/x-msgpack' + if bin_type: + response.content_type = 'application/x-msgpack-bin' return msgpack.packb(value, use_bin_type=bin_type) return _render