MCPcopy Create free account
hub / github.com/LUX-Core/lux / __init__

Method __init__

test/functional/test_framework/authproxy.py:76–105  ·  view source on GitHub ↗
(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None, ensure_ascii=True)

Source from the content-addressed store, hash-verified

74
75 # ensure_ascii: escape unicode as \uXXXX, passed to json.dumps
76 def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT, connection=None, ensure_ascii=True):
77 self.__service_url = service_url
78 self._service_name = service_name
79 self.ensure_ascii = ensure_ascii # can be toggled on the fly by tests
80 self.__url = urlparse.urlparse(service_url)
81 if self.__url.port is None:
82 port = 80
83 else:
84 port = self.__url.port
85 (user, passwd) = (self.__url.username, self.__url.password)
86 try:
87 user = user.encode('utf8')
88 except AttributeError:
89 pass
90 try:
91 passwd = passwd.encode('utf8')
92 except AttributeError:
93 pass
94 authpair = user + b':' + passwd
95 self.__auth_header = b'Basic ' + base64.b64encode(authpair)
96
97 if connection:
98 # Callables re-use the connection of the original proxy
99 self.__conn = connection
100 elif self.__url.scheme == 'https':
101 self.__conn = httplib.HTTPSConnection(self.__url.hostname, port,
102 timeout=timeout)
103 else:
104 self.__conn = httplib.HTTPConnection(self.__url.hostname, port,
105 timeout=timeout)
106
107 def __getattr__(self, name):
108 if name.startswith('__') and name.endswith('__'):

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected