Show More
@@ -17,7 +17,6 b' import struct' | |||
|
17 | 17 | from .i18n import _ |
|
18 | 18 | from .thirdparty import ( |
|
19 | 19 | attr, |
|
20 | cbor, | |
|
21 | 20 | ) |
|
22 | 21 | from . import ( |
|
23 | 22 | encoding, |
@@ -25,6 +24,7 b' from . import (' | |||
|
25 | 24 | util, |
|
26 | 25 | ) |
|
27 | 26 | from .utils import ( |
|
27 | cborutil, | |
|
28 | 28 | stringutil, |
|
29 | 29 | ) |
|
30 | 30 | |
@@ -217,8 +217,8 b' def makeframefromhumanstring(s):' | |||
|
217 | 217 | finalflags |= int(flag) |
|
218 | 218 | |
|
219 | 219 | if payload.startswith(b'cbor:'): |
|
220 | payload = cbor.dumps(stringutil.evalpythonliteral(payload[5:]), | |
|
221 | canonical=True) | |
|
220 | payload = b''.join(cborutil.streamencode( | |
|
221 | stringutil.evalpythonliteral(payload[5:]))) | |
|
222 | 222 | |
|
223 | 223 | else: |
|
224 | 224 | payload = stringutil.unescapestr(payload) |
@@ -289,7 +289,7 b' def createcommandframes(stream, requesti' | |||
|
289 | 289 | if args: |
|
290 | 290 | data[b'args'] = args |
|
291 | 291 | |
|
292 | data = cbor.dumps(data, canonical=True) | |
|
292 | data = b''.join(cborutil.streamencode(data)) | |
|
293 | 293 | |
|
294 | 294 | offset = 0 |
|
295 | 295 | |
@@ -347,7 +347,7 b' def createcommandresponseframesfrombytes' | |||
|
347 | 347 | Returns a generator of bytearrays. |
|
348 | 348 | """ |
|
349 | 349 | # Automatically send the overall CBOR response map. |
|
350 |
overall = |
|
|
350 | overall = b''.join(cborutil.streamencode({b'status': b'ok'})) | |
|
351 | 351 | if len(overall) > maxframesize: |
|
352 | 352 | raise error.ProgrammingError('not yet implemented') |
|
353 | 353 | |
@@ -388,7 +388,7 b' def createcommandresponseframesfrombytes' | |||
|
388 | 388 | |
|
389 | 389 | def createbytesresponseframesfromgen(stream, requestid, gen, |
|
390 | 390 | maxframesize=DEFAULT_MAX_FRAME_SIZE): |
|
391 |
overall = |
|
|
391 | overall = b''.join(cborutil.streamencode({b'status': b'ok'})) | |
|
392 | 392 | |
|
393 | 393 | yield stream.makeframe(requestid=requestid, |
|
394 | 394 | typeid=FRAME_TYPE_COMMAND_RESPONSE, |
@@ -429,7 +429,7 b' def createcommanderrorresponse(stream, r' | |||
|
429 | 429 | if args: |
|
430 | 430 | m[b'error'][b'args'] = args |
|
431 | 431 | |
|
432 | overall = cbor.dumps(m, canonical=True) | |
|
432 | overall = b''.join(cborutil.streamencode(m)) | |
|
433 | 433 | |
|
434 | 434 | yield stream.makeframe(requestid=requestid, |
|
435 | 435 | typeid=FRAME_TYPE_COMMAND_RESPONSE, |
@@ -440,10 +440,10 b' def createerrorframe(stream, requestid, ' | |||
|
440 | 440 | # TODO properly handle frame size limits. |
|
441 | 441 | assert len(msg) <= DEFAULT_MAX_FRAME_SIZE |
|
442 | 442 | |
|
443 |
payload = |
|
|
443 | payload = b''.join(cborutil.streamencode({ | |
|
444 | 444 | b'type': errtype, |
|
445 | 445 | b'message': [{b'msg': msg}], |
|
446 | }, canonical=True) | |
|
446 | })) | |
|
447 | 447 | |
|
448 | 448 | yield stream.makeframe(requestid=requestid, |
|
449 | 449 | typeid=FRAME_TYPE_ERROR_RESPONSE, |
@@ -493,7 +493,7 b' def createtextoutputframe(stream, reques' | |||
|
493 | 493 | |
|
494 | 494 | atomdicts.append(atom) |
|
495 | 495 | |
|
496 | payload = cbor.dumps(atomdicts, canonical=True) | |
|
496 | payload = b''.join(cborutil.streamencode(atomdicts)) | |
|
497 | 497 | |
|
498 | 498 | if len(payload) > maxframesize: |
|
499 | 499 | raise ValueError('cannot encode data in a single frame') |
@@ -784,7 +784,7 b' class serverreactor(object):' | |||
|
784 | 784 | |
|
785 | 785 | # Decode the payloads as CBOR. |
|
786 | 786 | entry['payload'].seek(0) |
|
787 |
request = cbor. |
|
|
787 | request = cborutil.decodeall(entry['payload'].getvalue())[0] | |
|
788 | 788 | |
|
789 | 789 | if b'name' not in request: |
|
790 | 790 | self._state = 'errored' |
@@ -1158,7 +1158,7 b' class clientreactor(object):' | |||
|
1158 | 1158 | del self._activerequests[request.requestid] |
|
1159 | 1159 | |
|
1160 | 1160 | # The payload should be a CBOR map. |
|
1161 |
m = cbor. |
|
|
1161 | m = cborutil.decodeall(frame.payload)[0] | |
|
1162 | 1162 | |
|
1163 | 1163 | return 'error', { |
|
1164 | 1164 | 'request': request, |
@@ -406,7 +406,7 b' Command frames can be reflected via debu' | |||
|
406 | 406 | s> content-length: 47\r\n |
|
407 | 407 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
408 | 408 | s> \r\n |
|
409 |
s> \'\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2CfooDval1 |
|
|
409 | s> \'\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1 | |
|
410 | 410 | s> makefile('rb', None) |
|
411 | 411 | s> HTTP/1.1 200 OK\r\n |
|
412 | 412 | s> Server: testing stub value\r\n |
@@ -414,7 +414,7 b' Command frames can be reflected via debu' | |||
|
414 | 414 | s> Content-Type: text/plain\r\n |
|
415 | 415 | s> Content-Length: 205\r\n |
|
416 | 416 | s> \r\n |
|
417 |
s> received: 1 1 1 \xa2Dargs\xa2CfooDval1 |
|
|
417 | s> received: 1 1 1 \xa2Dargs\xa2Dbar1CvalCfooDval1DnameHcommand1\n | |
|
418 | 418 | s> ["runcommand", {"args": {"bar1": "val", "foo": "val1"}, "command": "command1", "data": null, "requestid": 1}]\n |
|
419 | 419 | s> received: <no frame>\n |
|
420 | 420 | s> {"action": "noop"} |
@@ -38,7 +38,7 b' pushkey for a bookmark works' | |||
|
38 | 38 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
39 | 39 | s> user-agent: Mercurial debugwireproto\r\n |
|
40 | 40 | s> \r\n |
|
41 |
s> a\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa4CkeyA@CnewX(426bada5c67598ca65036d57d9e4b64b0c1ce7a0Cold@ |
|
|
41 | s> a\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa4CkeyA@InamespaceIbookmarksCnewX(426bada5c67598ca65036d57d9e4b64b0c1ce7a0Cold@DnameGpushkey | |
|
42 | 42 | s> makefile('rb', None) |
|
43 | 43 | s> HTTP/1.1 200 OK\r\n |
|
44 | 44 | s> Server: testing stub value\r\n |
General Comments 0
You need to be logged in to leave comments.
Login now