diff -r 1fc39367eafd -r 98995b689e03 mercurial/httppeer.py --- a/mercurial/httppeer.py Sat Sep 08 23:57:07 2018 +0800 +++ b/mercurial/httppeer.py Sat Sep 08 21:58:51 2018 +0800 @@ -401,8 +401,8 @@ elif version_info == (0, 2): # application/mercurial-0.2 always identifies the compression # engine in the payload header. - elen = struct.unpack('B', resp.read(1))[0] - ename = resp.read(elen) + elen = struct.unpack('B', util.readexactly(resp, 1))[0] + ename = util.readexactly(resp, elen) engine = util.compengines.forwiretype(ename) resp = engine.decompressorreader(resp)