S
Sahasranaman
Hi
I am behind a proxy server that needs proxy authentication. There are
a lot of libraries that come without proxy support. The function
below, which is part of the python-twitter library does HTTP
Authentication, and I can't figure out how to do this with a
ProxyBasicAuthHandler object. I'm pasting the function here. Can
someone tell me how this code can be rewritten to do proxy
authentication as well as http authentication?
def _GetOpener(self, url, username=None, password=None):
if username and password:
self._AddAuthorizationHeader(username, password)
handler = self._urllib.HTTPBasicAuthHandler()
(scheme, netloc, path, params, query, fragment) =
urlparse.urlparse(url)
handler.add_password(Api._API_REALM, netloc, username, password)
opener = self._urllib.build_opener(handler)
else:
opener = self._urllib.build_opener()
opener.addheaders = self._request_headers.items()
return opener
I am behind a proxy server that needs proxy authentication. There are
a lot of libraries that come without proxy support. The function
below, which is part of the python-twitter library does HTTP
Authentication, and I can't figure out how to do this with a
ProxyBasicAuthHandler object. I'm pasting the function here. Can
someone tell me how this code can be rewritten to do proxy
authentication as well as http authentication?
def _GetOpener(self, url, username=None, password=None):
if username and password:
self._AddAuthorizationHeader(username, password)
handler = self._urllib.HTTPBasicAuthHandler()
(scheme, netloc, path, params, query, fragment) =
urlparse.urlparse(url)
handler.add_password(Api._API_REALM, netloc, username, password)
opener = self._urllib.build_opener(handler)
else:
opener = self._urllib.build_opener()
opener.addheaders = self._request_headers.items()
return opener