Show More
@@ -466,25 +466,40 class sshv1peer(wireproto.wirepeer): | |||||
466 | return self._sendrequest(cmd, args, framed=True).read() |
|
466 | return self._sendrequest(cmd, args, framed=True).read() | |
467 |
|
467 | |||
468 | def _callpush(self, cmd, fp, **args): |
|
468 | def _callpush(self, cmd, fp, **args): | |
|
469 | # The server responds with an empty frame if the client should | |||
|
470 | # continue submitting the payload. | |||
469 | r = self._call(cmd, **args) |
|
471 | r = self._call(cmd, **args) | |
470 | if r: |
|
472 | if r: | |
471 | return '', r |
|
473 | return '', r | |
|
474 | ||||
|
475 | # The payload consists of frames with content followed by an empty | |||
|
476 | # frame. | |||
472 | for d in iter(lambda: fp.read(4096), ''): |
|
477 | for d in iter(lambda: fp.read(4096), ''): | |
473 | self._writeframed(d) |
|
478 | self._writeframed(d) | |
474 | self._writeframed("", flush=True) |
|
479 | self._writeframed("", flush=True) | |
|
480 | ||||
|
481 | # In case of success, there is an empty frame and a frame containing | |||
|
482 | # the integer result (as a string). | |||
|
483 | # In case of error, there is a non-empty frame containing the error. | |||
475 | r = self._readframed() |
|
484 | r = self._readframed() | |
476 | if r: |
|
485 | if r: | |
477 | return '', r |
|
486 | return '', r | |
478 | return self._readframed(), '' |
|
487 | return self._readframed(), '' | |
479 |
|
488 | |||
480 | def _calltwowaystream(self, cmd, fp, **args): |
|
489 | def _calltwowaystream(self, cmd, fp, **args): | |
|
490 | # The server responds with an empty frame if the client should | |||
|
491 | # continue submitting the payload. | |||
481 | r = self._call(cmd, **args) |
|
492 | r = self._call(cmd, **args) | |
482 | if r: |
|
493 | if r: | |
483 | # XXX needs to be made better |
|
494 | # XXX needs to be made better | |
484 | raise error.Abort(_('unexpected remote reply: %s') % r) |
|
495 | raise error.Abort(_('unexpected remote reply: %s') % r) | |
|
496 | ||||
|
497 | # The payload consists of frames with content followed by an empty | |||
|
498 | # frame. | |||
485 | for d in iter(lambda: fp.read(4096), ''): |
|
499 | for d in iter(lambda: fp.read(4096), ''): | |
486 | self._writeframed(d) |
|
500 | self._writeframed(d) | |
487 | self._writeframed("", flush=True) |
|
501 | self._writeframed("", flush=True) | |
|
502 | ||||
488 | return self._pipei |
|
503 | return self._pipei | |
489 |
|
504 | |||
490 | def _getamount(self): |
|
505 | def _getamount(self): |
@@ -347,12 +347,16 class sshv1protocolhandler(wireprototype | |||||
347 | return [data[k] for k in keys] |
|
347 | return [data[k] for k in keys] | |
348 |
|
348 | |||
349 | def forwardpayload(self, fpout): |
|
349 | def forwardpayload(self, fpout): | |
|
350 | # We initially send an empty response. This tells the client it is | |||
|
351 | # OK to start sending data. If a client sees any other response, it | |||
|
352 | # interprets it as an error. | |||
|
353 | _sshv1respondbytes(self._fout, b'') | |||
|
354 | ||||
350 | # The file is in the form: |
|
355 | # The file is in the form: | |
351 | # |
|
356 | # | |
352 | # <chunk size>\n<chunk> |
|
357 | # <chunk size>\n<chunk> | |
353 | # ... |
|
358 | # ... | |
354 | # 0\n |
|
359 | # 0\n | |
355 | _sshv1respondbytes(self._fout, b'') |
|
|||
356 | count = int(self._fin.readline()) |
|
360 | count = int(self._fin.readline()) | |
357 | while count: |
|
361 | while count: | |
358 | fpout.write(self._fin.read(count)) |
|
362 | fpout.write(self._fin.read(count)) |
General Comments 0
You need to be logged in to leave comments.
Login now