mercurial/wireprotoframing.py
changeset 37725 3ea8323d6f95
parent 37724 deff7cf7eefd
child 37726 0c184ca594bb
--- a/mercurial/wireprotoframing.py	Sat Apr 14 14:37:23 2018 -0700
+++ b/mercurial/wireprotoframing.py	Sat Apr 14 15:19:36 2018 -0700
@@ -354,16 +354,27 @@
 
     Returns a generator of bytearrays.
     """
+    # Automatically send the overall CBOR response map.
+    overall = cbor.dumps({b'status': b'ok'}, canonical=True)
+    if len(overall) > maxframesize:
+        raise error.ProgrammingError('not yet implemented')
 
-    # Simple case of a single frame.
-    if len(data) <= maxframesize:
+    # Simple case where we can fit the full response in a single frame.
+    if len(overall) + len(data) <= maxframesize:
         flags = FLAG_COMMAND_RESPONSE_EOS
         yield stream.makeframe(requestid=requestid,
                                typeid=FRAME_TYPE_COMMAND_RESPONSE,
                                flags=flags,
-                               payload=data)
+                               payload=overall + data)
         return
 
+    # It's easier to send the overall CBOR map in its own frame than to track
+    # offsets.
+    yield stream.makeframe(requestid=requestid,
+                           typeid=FRAME_TYPE_COMMAND_RESPONSE,
+                           flags=FLAG_COMMAND_RESPONSE_CONTINUATION,
+                           payload=overall)
+
     offset = 0
     while True:
         chunk = data[offset:offset + maxframesize]