# HG changeset patch # User RhodeCode Admin # Date 2023-06-06 08:53:45 # Node ID eadcb91adf5f3fafdd97831c406cdf977f5d762d # Parent 8665da11fb1772934e3ea63b06d75159a1f61c74 binary envelope: add support for custom response type when using wrapped binary data in envelope 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