diff mercurial/keepalive.py @ 34466:1232f7fa00c3

cleanup: use urllibcompat for renamed methods on urllib request objects Differential Revision: https://phab.mercurial-scm.org/D891
author Augie Fackler <augie@google.com>
date Sun, 01 Oct 2017 12:14:21 -0400
parents 5326e4ef1dab
children 03112a2c9c83
line wrap: on
line diff
--- a/mercurial/keepalive.py	Sun Oct 01 10:45:03 2017 -0400
+++ b/mercurial/keepalive.py	Sun Oct 01 12:14:21 2017 -0400
@@ -93,6 +93,7 @@
 from .i18n import _
 from . import (
     pycompat,
+    urllibcompat,
     util,
 )
 
@@ -206,7 +207,7 @@
         return self.do_open(HTTPConnection, req)
 
     def do_open(self, http_class, req):
-        host = req.get_host()
+        host = urllibcompat.gethost(req)
         if not host:
             raise urlerr.urlerror('no host given')
 
@@ -317,10 +318,11 @@
             if n in headers:
                 skipheaders['skip_' + n.replace('-', '_')] = 1
         try:
-            if req.has_data():
-                data = req.get_data()
+            if urllibcompat.hasdata(req):
+                data = urllibcompat.getdata(req)
                 h.putrequest(
-                    req.get_method(), req.get_selector(), **skipheaders)
+                    req.get_method(), urllibcompat.getselector(req),
+                    **skipheaders)
                 if 'content-type' not in headers:
                     h.putheader('Content-type',
                                 'application/x-www-form-urlencoded')
@@ -328,13 +330,14 @@
                     h.putheader('Content-length', '%d' % len(data))
             else:
                 h.putrequest(
-                    req.get_method(), req.get_selector(), **skipheaders)
+                    req.get_method(), urllibcompat.getselector(req),
+                    **skipheaders)
         except socket.error as err:
             raise urlerr.urlerror(err)
         for k, v in headers.items():
             h.putheader(k, v)
         h.endheaders()
-        if req.has_data():
+        if urllibcompat.hasdata(req):
             h.send(data)
 
 class HTTPHandler(KeepAliveHandler, urlreq.httphandler):