Mercurial > hg-stable
changeset 37297:97eedbd5a56c
keepalive: implement readinto()
This is part of the standard I/O interface. It is used by the framing
protocol. So we need to implement it so frames can be decoded.
Differential Revision: https://phab.mercurial-scm.org/D2984
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 12:44:35 -0700 |
parents | 78103e4138b1 |
children | 5ef2da00e935 |
files | mercurial/keepalive.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/keepalive.py Fri Mar 23 16:24:53 2018 -0700 +++ b/mercurial/keepalive.py Wed Mar 28 12:44:35 2018 -0700 @@ -349,7 +349,7 @@ class HTTPResponse(httplib.HTTPResponse): # we need to subclass HTTPResponse in order to - # 1) add readline() and readlines() methods + # 1) add readline(), readlines(), and readinto() methods # 2) add close_connection() methods # 3) add info() and geturl() methods @@ -522,6 +522,14 @@ break return list + def readinto(self, dest): + res = self.read(len(dest)) + if not res: + return 0 + + dest[0:len(res)] = res + return len(res) + def safesend(self, str): """Send `str' to the server.