linkchecker/linkcheck/ProxyUrlData.py
2002-10-15 00:59:12 +00:00

21 lines
821 B
Python

from UrlData import UrlData
from urllib import splittype, splithost, splituser, splitpasswd
class ProxyUrlData (UrlData):
"""urldata with ability for proxying"""
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