Proxy authentication in common libraries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sahasranaman

    Proxy authentication in common libraries

    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
    ProxyBasicAuthH andler 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._AddAuthor izationHeader(u sername, password)
    handler = self._urllib.HT TPBasicAuthHand ler()
    (scheme, netloc, path, params, query, fragment) =
    urlparse.urlpar se(url)
    handler.add_pas sword(Api._API_ REALM, netloc, username, password)
    opener = self._urllib.bu ild_opener(hand ler)
    else:
    opener = self._urllib.bu ild_opener()
    opener.addheade rs = self._request_h eaders.items()
    return opener
Working...