Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG03112a2c9c83: py3: handle keyword arguments correctly in keepalive.py
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
for n in ('host', 'accept-encoding'): | for n in ('host', 'accept-encoding'): | ||||
if n in headers: | if n in headers: | ||||
skipheaders['skip_' + n.replace('-', '_')] = 1 | skipheaders['skip_' + n.replace('-', '_')] = 1 | ||||
try: | try: | ||||
if urllibcompat.hasdata(req): | if urllibcompat.hasdata(req): | ||||
data = urllibcompat.getdata(req) | data = urllibcompat.getdata(req) | ||||
h.putrequest( | h.putrequest( | ||||
req.get_method(), urllibcompat.getselector(req), | req.get_method(), urllibcompat.getselector(req), | ||||
**skipheaders) | **pycompat.strkwargs(skipheaders)) | ||||
if 'content-type' not in headers: | if 'content-type' not in headers: | ||||
h.putheader('Content-type', | h.putheader('Content-type', | ||||
'application/x-www-form-urlencoded') | 'application/x-www-form-urlencoded') | ||||
if 'content-length' not in headers: | if 'content-length' not in headers: | ||||
h.putheader('Content-length', '%d' % len(data)) | h.putheader('Content-length', '%d' % len(data)) | ||||
else: | else: | ||||
h.putrequest( | h.putrequest( | ||||
req.get_method(), urllibcompat.getselector(req), | req.get_method(), urllibcompat.getselector(req), | ||||
**skipheaders) | **pycompat.strkwargs(skipheaders)) | ||||
except socket.error as err: | except socket.error as err: | ||||
raise urlerr.urlerror(err) | raise urlerr.urlerror(err) | ||||
for k, v in headers.items(): | for k, v in headers.items(): | ||||
h.putheader(k, v) | h.putheader(k, v) | ||||
h.endheaders() | h.endheaders() | ||||
if urllibcompat.hasdata(req): | if urllibcompat.hasdata(req): | ||||
h.send(data) | h.send(data) | ||||
# although read() never adds to the buffer. | # although read() never adds to the buffer. | ||||
# Both readline and readlines have been stolen with almost no | # Both readline and readlines have been stolen with almost no | ||||
# modification from socket.py | # modification from socket.py | ||||
def __init__(self, sock, debuglevel=0, strict=0, method=None): | def __init__(self, sock, debuglevel=0, strict=0, method=None): | ||||
extrakw = {} | extrakw = {} | ||||
if not pycompat.ispy3: | if not pycompat.ispy3: | ||||
extrakw['strict'] = True | extrakw[r'strict'] = True | ||||
extrakw['buffering'] = True | extrakw[r'buffering'] = True | ||||
httplib.HTTPResponse.__init__(self, sock, debuglevel=debuglevel, | httplib.HTTPResponse.__init__(self, sock, debuglevel=debuglevel, | ||||
method=method, **extrakw) | method=method, **extrakw) | ||||
self.fileno = sock.fileno | self.fileno = sock.fileno | ||||
self.code = None | self.code = None | ||||
self._rbuf = '' | self._rbuf = '' | ||||
self._rbufsize = 8096 | self._rbufsize = 8096 | ||||
self._handler = None # inserted by the handler later | self._handler = None # inserted by the handler later | ||||
self._host = None # (same) | self._host = None # (same) |