Fix wrong namespaces

This commit is contained in:
Yoshito Komatsu 2015-04-30 22:37:06 +09:00
parent c369bc1a74
commit 48cc60b11c

View File

@ -267,10 +267,10 @@ def query(url,
result_text = result.text result_text = result.text
result_cookies = result.cookies result_cookies = result.cookies
else: else:
request = urllib.Request(url, data) request = urllib.request.Request(url, data)
handlers = [ handlers = [
urllib.HTTPHandler, urllib.request.HTTPHandler,
urllib.HTTPCookieProcessor(sess_cookies) urllib.request.HTTPCookieProcessor(sess_cookies)
] ]
if url.startswith('https') or port == 443: if url.startswith('https') or port == 443:
@ -316,7 +316,7 @@ def query(url,
if hasattr(ssl, 'SSLContext'): if hasattr(ssl, 'SSLContext'):
# Python >= 2.7.9 # Python >= 2.7.9
context = ssl.SSLContext.load_cert_chain(*cert_chain) context = ssl.SSLContext.load_cert_chain(*cert_chain)
handlers.append(urllib.HTTPSHandler(context=context)) # pylint: disable=E1123 handlers.append(urllib.request.HTTPSHandler(context=context)) # pylint: disable=E1123
else: else:
# Python < 2.7.9 # Python < 2.7.9
cert_kwargs = { cert_kwargs = {
@ -328,7 +328,7 @@ def query(url,
cert_kwargs['key_file'] = cert_chain[1] cert_kwargs['key_file'] = cert_chain[1]
handlers[0] = salt.ext.six.moves.http_client.HTTPSConnection(**cert_kwargs) handlers[0] = salt.ext.six.moves.http_client.HTTPSConnection(**cert_kwargs)
opener = urllib.build_opener(*handlers) opener = urllib.request.build_opener(*handlers)
for header in header_dict: for header in header_dict:
request.add_header(header, header_dict[header]) request.add_header(header, header_dict[header])
request.get_method = lambda: method request.get_method = lambda: method