Patchwork D2984: keepalive: implement readinto()

login
register
mail settings
Submitter phabricator
Date April 3, 2018, 4:51 p.m.
Message ID <a97032598cf6df47d0f237eb5e96c174@localhost.localdomain>
Download mbox | patch
Permalink /patch/30189/
State Not Applicable
Headers show

Comments

phabricator - April 3, 2018, 4:51 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG97eedbd5a56c: keepalive: implement readinto() (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2984?vs=7447&id=7558

REVISION DETAIL
  https://phab.mercurial-scm.org/D2984

AFFECTED FILES
  mercurial/keepalive.py

CHANGE DETAILS




To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -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.