# HG changeset patch # User Gregory Szorc # Date 2018-03-28 19:44:35 # Node ID 97eedbd5a56cf7d98b479604e16dc0a749356ffa # Parent 78103e4138b1076c55d99cd9029d7be56fdf9f5b 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 diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -349,7 +349,7 @@ class HTTPHandler(KeepAliveHandler, urlr 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 @@ class HTTPResponse(httplib.HTTPResponse) 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.