2002-10-15 00:59:12 +00:00
|
|
|
from UrlData import UrlData
|
2003-01-05 12:38:34 +00:00
|
|
|
from urllib import splittype, splithost, splituser
|
2002-10-15 00:59:12 +00:00
|
|
|
|
|
|
|
|
class ProxyUrlData (UrlData):
|
2002-12-06 01:36:19 +00:00
|
|
|
"""urldata with ability for proxying and for urls with user:pass@host
|
|
|
|
|
setting"""
|
2002-10-15 00:59:12 +00:00
|
|
|
|
|
|
|
|
def setProxy (self, proxy):
|
|
|
|
|
self.proxy = proxy
|
|
|
|
|
self.proxyauth = None
|
|
|
|
|
if self.proxy:
|
|
|
|
|
if self.proxy[:7].lower() != "http://":
|
|
|
|
|
self.proxy = "http://"+self.proxy
|
|
|
|
|
self.proxy = splittype(self.proxy)[1]
|
|
|
|
|
self.proxy = splithost(self.proxy)[0]
|
|
|
|
|
self.proxyauth, self.proxy = splituser(self.proxy)
|
|
|
|
|
if self.proxyauth is not None:
|
|
|
|
|
if ":" not in self.proxyauth: self.proxyauth += ":"
|
|
|
|
|
import base64
|
|
|
|
|
self.proxyauth = base64.encodestring(self.proxyauth).strip()
|
|
|
|
|
self.proxyauth = "Basic "+self.proxyauth
|
|
|
|
|
|