def _get_proxy_info(url): proxy_info = {} url_info = urlsplit(url) # If the url contains a username, need to separate the username/password # from the url if url_info.username: # Strip the username/password out of the url url = url_info.netloc[url_info.netloc.find('@')+1:] # Now get the username and possibly password proxy_info['proxy_url'] = '{0}://{1}'.format(url_info.scheme, url) if url_info.password: proxy_auth = '{0}:{1}'.format(url_info.username, url_info.password) else: proxy_auth = url_info.username proxy_info['proxy_headers'] = urllib3.make_headers(proxy_basic_auth=proxy_auth) else: # No username was given, so just take the url as is. proxy_info['proxy_url'] = url return proxy_info
def _get_proxy_info(url): proxy_info = {} url_info = urlsplit(url) # If the url contains a username, need to separate the username/password # from the url if url_info.username: # Strip the username/password out of the url url = url_info.netloc[url_info.netloc.find('@')+1:] # Now get the username and possibly password proxy_info['proxy_url'] = '{0}://{1}'.format(url_info.scheme, url) if url_info.password: proxy_auth = '{0}:{1}'.format(url_info.username, url_info.password) else: proxy_auth = url_info.username proxy_info['proxy_headers'] = urllib3.make_headers(proxy_basic_auth=proxy_auth) else: # No username was given, so just take the url as is. proxy_info['proxy_url'] = url return proxy_info