Skip to content

Commit 3b8fae8

Browse files
author
Luiko Czub
committed
ProxiedTransport usable with PY3 #38
1 parent 2e7434a commit 3b8fae8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/testlink/proxiedtransport.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,27 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
import xmlrpclib, httplib
20+
import sys
21+
IS_PY3 = sys.version_info[0] > 2
22+
if IS_PY3:
23+
from xmlrpc.client import Transport
24+
from http.client import HTTPConnection
25+
else:
26+
from xmlrpclib import Transport
27+
from httplib import HTTPConnection
28+
2129
try:
2230
import gzip
2331
except ImportError:
2432
gzip = None #python can be built without zlib/gzip support
2533

2634

27-
class ProxiedTransport(xmlrpclib.Transport):
35+
class ProxiedTransport(Transport):
2836
def __init__(self):
29-
xmlrpclib.Transport.__init__(self)
37+
if IS_PY3:
38+
super(ProxiedTransport, self).__init__()
39+
else:
40+
Transport.__init__(self)
3041
self.realhost = None
3142
self.proxy = None
3243

@@ -61,7 +72,7 @@ def make_connection(self, host):
6172
else:
6273
self._extra_headers = auth
6374
self.realhost = host
64-
self._connection = host, httplib.HTTPConnection(self.proxy)
75+
self._connection = host, HTTPConnection(self.proxy)
6576
return self._connection[1]
6677

6778
def send_request(self, connection, handler, request_body):

0 commit comments

Comments
 (0)