mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-22 08:50:24 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@569 e7d03fd6-7b0d-0410-9947-9c21f3af8025
21 lines
821 B
Python
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
|
|
|