##// END OF EJS Templates
binary envelope: add support for custom response type when using wrapped binary data in envelope
super-admin -
r1107:eadcb91a python3
parent child Browse files
Show More
@@ -137,7 +137,7 b' def archive_repo(walker, archive_dest_pa'
137
137
138
138
139 class BinaryEnvelope(object):
139 class BinaryEnvelope(object):
140 def __init__(self, value, bin_type=True):
140 def __init__(self, value: bytes, bin_type=True):
141 self.value = value
141 self.value = value
142 self.bin_type = bin_type
142 self.bin_type = bin_type
143
143
@@ -72,7 +72,8 b' from mercurial import strip as hgext_str'
72
72
73
73
74 def get_ctx(repo, ref):
74 def get_ctx(repo, ref):
75 ref = safe_bytes(ref)
75 if not isinstance(ref, int):
76 ref = safe_bytes(ref)
76 try:
77 try:
77 ctx = repo[ref]
78 ctx = repo[ref]
78 except (ProgrammingError, TypeError):
79 except (ProgrammingError, TypeError):
@@ -507,6 +507,7 b' class HTTPApplication(object):'
507 bin_type = False
507 bin_type = False
508 res = value.get('result')
508 res = value.get('result')
509 if res and isinstance(res, BinaryEnvelope):
509 if res and isinstance(res, BinaryEnvelope):
510 log.debug('Result is wrapped in BinaryEnvelope type')
510 value['result'] = res.value
511 value['result'] = res.value
511 bin_type = res.bin_type
512 bin_type = res.bin_type
512
513
@@ -516,6 +517,8 b' class HTTPApplication(object):'
516 ct = response.content_type
517 ct = response.content_type
517 if ct == response.default_content_type:
518 if ct == response.default_content_type:
518 response.content_type = 'application/x-msgpack'
519 response.content_type = 'application/x-msgpack'
520 if bin_type:
521 response.content_type = 'application/x-msgpack-bin'
519
522
520 return msgpack.packb(value, use_bin_type=bin_type)
523 return msgpack.packb(value, use_bin_type=bin_type)
521 return _render
524 return _render
General Comments 0
You need to be logged in to leave comments. Login now